我有这个指令:
(function () {
"use strict";
angular.module("siteObjects").directive("siteObjectsList", [newObjectsLits]);
function newObjectsLits() {
var directive = {
restrict: "E",
scope: {
objects: "=",
region: "=",
contractid: "=",
//isannual:"="
},
link: function (scope) {
scope.name = 'Jeff';
},
templateUrl: "app/siteObjects/templates/siteObjectsListDirective.tmpl.html",
controller: "siteObjectsListController",
controllerAs: "list"
}
return directive;
}
})();
控制器:
(function () {
"use strict";
angular.module("siteObjects").controller("siteObjectsListController", ["$scope","config","toaster",
siteObjectsListController]);
function siteObjectsListController($scope,
config, toaster
) {
$scope.test = function (shRev,index) {
var dx = index;
var is = shRev;
}
function getPhotoUrl(item) {
return config.baseUrl + "api/siteobjects/" + $scope.region.Id + "/photo/" + item.Id;
}
function zoomSiteObject(object) {
siteObjectsService.zoomObject(object);
}
}
})();
在指令辩护中,我有链接:
link: function (scope) { scope.name = 'Jeff';}
当我尝试在控制器中访问来自链接的名称属性时,例如:
var myName = $scope.name;
myName未定义。
知道为什么我无法获得$ scope.name属性值吗?