1. Custom Directive
app.directive('inputField', function() {
return {
restrict: 'E',
require: 'ngModel',
scope: {
words: '=ngModel'
},
transclude: true,
template: "<input type='text' ng-model='words' placeholder='Translate' />"
};
});
2. ng-click Function
$scope.clear = function() {
$scope.words = { word: '' };
};
3. View Structure
<input-field id='inputWord' value='' name="data1" ng-model="words.word"></input-field>
Issue After Clearing
{{words.word}}
and the input value still remains, causing a broken $scope.Seeking advice on clearing all inputs within a ng-repeat
and updating the scope accordingly.