<!DOCTYPE>
<html>
<head>
<script src="/scripts/angular/angular.min.js"></script>
<script type="text/javascript">
(function () {
var app = angular.module('ngCustomDirectiveTest', []);
app.controller('myController', ['$scope', function ($scope) {
$scope.jack = "TeaMasterSeaReport";
}]);
app.directive("studentInfo", function () {
return {
restrict: 'EA',
// 定义student-info的Isolate scope
scope: {
// 作用域内定义一个变量:newNameInScope
// 值对应到Directive中的info属性
info: '='
},
// template 不再依赖外部, 仅依赖内部的newNameInScope变量
template: '<div><p>{{info}}</p></div>'
};
});
app.directive('adgroup', function ($http) {
return {
restrict: 'EA',
//replace: true,
templateUrl: '/scripts/angular/directive/general/adgroup/template/v1.html',
scope: {
groupid: '@',
groupkey: '=',
},
link: function (scope, element, attrs) {
scope.DataSource = [];
$http.post("/json/GetAdGroupImgs", { Id: scope.groupid, GroupKey: scope.groupkey }).success(function (response) {
scope.DataSource = response;
});
}
}
});
})();
</script>
</head>
<body ng-app="ngCustomDirectiveTest">
<div ng-controller="myController as myCtrl">
<input type="text" ng-model="jack" />
<!--将myController中的jack属性传递给info-->
<student-info info="jack"></student-info>
<br />
<adgroup groupkey="jack"></adgroup>
</div>
</body>
</html>
[/code]
我希望的是当jack的值发生改变时能重新加载数据 也就是adgroup指令link里面的加载数据
但是这样实现不了,这是为啥。,,虽然jack的值变化了。。但是adgroup指令link并没有因为jack的值变化了 而去重新加载。。