I have been using Angular without $scope
Controller:
angular
.module('app')
.controller('requestController', requestController);
requestController.$inject = ['$location','requestService'];
function requestController($location, requestService) {
var vm = this;
//......
var detail = {};
detail.program.....
}
HTML page shows value
{{detail.program.code}} shows DGAT on page ... thus it has value
Pass it into a Directive
<com-code progCode="detail.program.code"></com-code>
Directive in which is supposed to take value in as two way binding
(function () {
var injectParams = ['customerService', '$sce'];
var comCode = function (customerService, $sce) {
return {
replace: true,
restrict: "E",
scope: {
progCode: "="
},
link: function (scope, element, attrs) {
console.log('scope.progCode',scope.progCode); // UNDEFINED
}
};
};
comCode.$inject = injectParams;
angular.module('app').directive('comCode', comCode)
}());
- Why is this
undefined
? - Is it from the lack of
$scope
in controller? - Does
progCode
as 2 way data binding become part of the scope in the directive?