我有一个角度指令:
app.directive('myStyle', function($location) {
return {
scope: {
myCSSFile: "="
},
//template: '<link href="style.css" rel="stylesheet" />',
template: '<link href="{{ myCSSFile }}.css" rel="stylesheet" />',
link: function(scope,el, attr) {
var absUrl = $location.absUrl();
console.log(absUrl);
if (absUrl == 'http://run.plnkr.co/KDRUOzkRgvgCzdzy/') {
console.log("Found");
scope.myCSSFile = 'style';
}
else {
console.log("Not found");
scope.myCSSFile = 'style2';
}
}
};
});
如何根据{{ myCSSFile }}
中的函数将值绑定到模板中的link
?