0
我已經開發了一些指令,並且在它們中我使用特定的模式命名屬性。所有的屬性前綴爲「fs-」,例如<div fs-attrtibute="value"></div>
在Angular指令中重命名需要ngModel
是否可以使用ngModel屬性的自定義名稱並仍保留模型控制器功能。例如<div fs-model="value" fsDirective></div>
myApp.directive('fsDirective', function() {
return {
require: 'fsModel',
link: function($scope, element, attrs, ngModel) {
ngModel.$setViewValue('StackOverflow');
};
}
};
});