0
我有以下指令:动态templateUrl在指令
Directives.js
module.directive('vdGuarantees', function() {
return {
restrict: 'A',
template: '<div ng-include="contentUrl"></div>',
link: function(scope, element, attrs) {
scope.contentUrl = '../../HTML/Directives/Guarantees/6787.html';
scope.$watch(scope.clientId, function (newValue, oldValue) {
console.log(scope.clientId);
//scope.contentUrl = '../../HTML/Directives/Guarantees/' + newValue + '.html'
});
}
};
});
HTML
<div vd-Guarantees></div>
以我控制器我已经定义$scope.clientId
作为一个空对象。在加载时,控制器正在向网络服务请求$http
,并在success
上填充$scope.clientId
。
我想要做的是,当clientId被填充时,相应地更改指令的templateUrl。