Reputation: 14216
I am setting up a temporary array to let users try and edit a few things and I'm trying to save a text input value to the arrary. The current method I am using is pushing something but it's showing up as a blank. I'm thinking I am not really getting the value from the text input correctly, have a look and see-
Here's the button and input
<input type="text" ng-module="tagName"><button type="button" class="resultsButton" ng-click="addTag()">Submit</button>
In my controller -
$scope.tagsFeed = ["one", "two", "thre", "four", "five", "six"];
//ignore delete function
$scope.deleteTag = function($index){
$scope.tagsFeed.splice($index,1);
};
$scope.addTag = function(){
$scope.tagsFeed.push($scope.tagName);
};
My add tag function however does not seem to be working correctly. Pushing the button adds a blank entry to the array, I tried to console.log $scope.tagName and it seems to come abck as undefined. Any thoughts? Thanks!
Upvotes: 0
Views: 3655
Reputation: 6657
Think you want ng-model
instead of ng-module
.
So change
<input type="text" ng-module="tagName">
To this:
<input type="text" ng-model="tagName">
Upvotes: 3