0
我注射值到定制指令,但该值未在指令模板显示:AngularJS DI字符串转换成指令
app.value('messageString', {
'to' : 'TO',
'startDate' : 'START DATE',
'endDate' : 'END DATE',
});
app.directive('dateRangePicker', function(messageString) {
return {
replace: true,
restrict: 'EA',
template: '<div class="input-group">' +
'<input type="text" class="form-control" placeholder="{{messageString.startDate}}" id="start-date" ng-model="startdate">' + // doesn't work in placeholder
'</div>',
link: function(scope, element, attributes) {
console.log(messageString.startDate); // works here
}
};
});
那么,什么地方出了错?
你必须将其连接到示波器的性能序结合工作,在你的链接函数做: - 'scope.messageString = messageString' – PSL 2014-10-30 01:33:11