AngularJS: помещение ng-transclude в переменную (ng-transclude в заполнитель)

У меня есть директива с транслируемым текстом, мне нужно поместить ее в заполнитель

Мой html

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

JS

(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>

person OvidijusR    schedule 09.09.2016    source источник
comment
Предоставьте свой шаблон my-dialog.html   -  person Hornth    schedule 09.09.2016


Ответы (1)


Существуют разные подходы к получению включенного контента. Посмотрите на этот вопрос

person Tobias Timm    schedule 09.09.2016