我有几个指令像共享变量
app.directive('navContent', function() {
return {
restrict: 'E',
scope: {
content: "="
},
templateUrl: '../../' + template + '/regions/nav.html',
}
});
app.directive('headerContent', function() {
return {
restrict: 'E',
scope: {
content: "="
},
templateUrl: '../../' + template + '/regions/header.html',
}
});
都需要在templateURL模板变种。
我有一个函数试图没有成功
var siteID = angular.element('head').data('site-id');
$http.get('/api/sites/' + siteID)
.success(function(site) {
var template = site.template;
})
.error(function(data) {
console.log('Error: ' + data);
});
};
的siteID是DOM:
<head data-site-id="123456">
和site.template应该从网站模式返回模板
任何帮助,将不胜感激
为什么你的'site.template'不在范围内的任何原因? –
也不合理把'template'作为数据属性,而不仅仅是'site-id'? – charlietfl
不是真的!你怎么看?我不知道如何使用超时获取值 – ZeGregg