我有一个名为dealEngine的指令,它有模板和控制器,工作正常。
但是你可以看到我正在尝试从属性中收集对象并将其传递给我的控制器!到目前为止,我得到undefined
或"string"
。
(function () {
'use strict';
angular
.module('app')
.directive('dealEngine', dealEngine)
.controller("dealEngineCtrl", dealEngineCtrl);
dealEngine.$inject = ['$state'];
function dealEngine($state) {
return {
restrict: 'E',
replace: 'true',
cache:'false',
controller: 'dealEngineCtrl',
templateUrl: 'directives/deal/deal.html',
scope:{
"deal":"="
}
};
}
dealEngineCtrl.$inject = ['$scope','$attrs', '$element'];
function dealEngineCtrl($scope, $attrs, $element) {
console.log($attrs.deal); //this returns "vm.deal" string!!!
console.log($scope.deal); //this returns undefined!!!
}
})();