0
Я пытаюсь скомпилировать директиву динамически. Эта директива имеет изоляционную область. Так что-то вроде этого:Как я могу ввести область выделения в директиву?
angular.module('mod').directive 'foo', ->
restrict: 'E'
templateUrl: 'foo.html'
scope:
text: '=text'
bindToController: true
replace: true
controllerAs: 'fooCtrl'
controller: ($scope) ->
console.log @ # .text undefined
console.log $scope # .text undefined
return
Вот как я компилирую:
template = "<foo></foo>"
scope = $rootScope.$new()
scope.text = "hello"
$compile(template) scope, (clone, innerScope) ->
angular.element('body').append clone
Однако когда @
регистрируется, текст undefined
. Как я могу передать область в свою директиву?