2016-09-09 2 views
3

나는 자리 안에AngularJS와 : 변수에 NG-transclude 퍼팅 (NG-transclude이 자리 표시 자)는

내 HTML

<div ng-controller="Controller"> 
    <my-dialog>Hello world!</my-dialog> 
    </div> 

JS를 넣을 필요가 transclude 텍스트와 지침을 가지고

(function(angular) { 
    'use strict'; 
angular.module('docsTransclusionDirective', []) 
    .controller('Controller', ['$scope', function($scope,$transclude) { 
    console.log($transclude); 
    $scope.name = $transclude; // I NEED TO GET HELLO WORLD HERE 

    }]) 
    .directive('myDialog', function() { 
    return { 
     restrict: 'E', 
     transclude: true, 
     scope: {}, 
     templateUrl: 'my-dialog.html' 
    }; 
    }); 
})(window.angular);\ 

내 템플릿

<div>this should give me transcluded text {{name}}</div> 
+0

템플릿 'my-dialog.html'을 제공해주십시오. – Hornth

답변