angularjs - Why I can't get scope property value defined in link? -
i have directive:
(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; } })();
controller:
(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 = shrev; } function getphotourl(item) { return config.baseurl + "api/siteobjects/" + $scope.region.id + "/photo/" + item.id; } function zoomsiteobject(object) { siteobjectsservice.zoomobject(object); } } })();
in directive defenition have link:
link: function (scope) { scope.name = 'jeff';}
when try access in controller name property link, that:
var myname = $scope.name;
myname undefined.
any idea why can't $scope.name property value?
Comments
Post a Comment