I need help with a basic AngularJS directive:
<my-directive ng-model="name"></my-directive>
I want to change the "ng-model" attribute to "model", but I'm unsure how to pass it to the "require" option in the directive. Here is the full code for the directive:
myApp.directive('myDirective', function($timeout) {
return {
restrict: 'E',
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
ngModel.$render = function() {
$timeout(function() {
ngModel.$setViewValue('StackOverflow');
}, 5000);
};
}
};
});
Here is a fiddle for testing: https://jsfiddle.net/cg2enqj2/1/
Any guidance on how (and if) this modification is possible would be greatly appreciated!
Thank you for your assistance!