1
当使用没有模板的自定义指令时(使用服务器生成的DOM)并将我的视图绑定到控制器时,我遇到了一个问题。没有模板控制器的角度指令绑定As
这里是我的jsfiddle样本:
angular.module('myModule', [])
.directive('myDirective', function(){
\t return {
\t bindToController: true,
\t controller: 'myController',
controllerAs: 'ctrl',
scope: {
text: '@'
},
}
})
.controller('myController', function($scope){
\t \t this.text = $scope.text
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
<div data-ng-app="myModule" data-my-directive='' data-text="Hello world!">
<h1>
{{ ctrl.text }}
</h1>
</div>
使用我的指令字符串模板或模板URL将作品中的相同的样品,但我需要使用的服务器DOM。
有没有人得到同样的问题并解决了它?
问候,