我在这里做错了什么?在 Angular JS 中,我试图将 ng-model 名称添加到自定义指令中,以便它与父范围绑定。我希望它看起来像这样:
<div use-date-picker this-ngmodel="something"></div>
The ng model: {{ something }}
我在指令中尝试了这个,但是我想通过属性传递的 ng-model 名称没有将它添加到模板中:
app.directive('useDatePicker', function() {
return {
restrict: 'A',
replace:true,
scope: {
thisNgmodel: '=',
//bindAttr: '='
},
template: '<div class="input-group">' +
'<input type="text" class="form-control" datepicker-popup="{{format}}" name="dt" ng-model=thisNgmodel is-open="datepickers.dt" datepicker-options="dateOptions" ng-required="true" close-text="Close" />' +
'<span class="input-group-btn">' +
'<button class="btn btn-default" ng-click="open($event,\'dt\')"><i class="glyphicon glyphicon-calendar"></i></button>' +
'</span>' +
'</div> ',
};
});
我究竟做错了什么?