是否可以在指令的templateUrl中获取$rootScope
对象?
我的意思是,如果这是我的指令的功能:
function AttributesCard() {
return {
restrict: "AE",
templateUrl: function ($rootScope) {
return $rootScope.baseUrl + "/attributesCard.directive.html";
},
controller: AttributesCardController,
controllerAs: "vm",
scope: {
educationPlace: "=",
privileges: "="
},
bindToController: true
};
}
我怎么得到templateUrl的函数中的$ rootScope对象?我在其中得到了一些其他的东西。或者,也许而不是$ rootScope可能为我获取这些数据的服务。
感谢,
ashilon
的可能的复制[如何访问指令templateUrl $ rootScope变量](https://stackoverflow.com/questions/36007277/how-to-access-rootscope-variable-from-directive-templateurl) – Vivz