代码如下:
angular.module('picker', {
}).directive('datepicker', function(){
return {
controllerAs:"datepickCtr",
restrict: 'A', // E = Element, A = Attribute, C = Class, M = Comment
templateUrl: 'datepicker.html',
replace:true,
//templateUrl: '',
// compile: function(tElement, tAttrs, function transclude(function(scope, cloneLinkingFn){ return function linking(scope, elm, attrs){}})),
link: function($scope, element, iAttrs) {
console.log("datepicker.html");//这个被打印
}
};
}).controller('datepickCtr', function(){
console.log("asd");//这个没有被打印
}).run(function ($templateCache){
$templateCache.put('datepicker.html',
'<div>asda</div>'
);
})
如代码所示,LINK部分正常打印,但是控制器没有被打印,求解
controllerAs -> controller