73
rated 0 times
[
75]
[
2]
/ answers: 1 / hits: 22896
/ 10 Years ago, sat, may 10, 2014, 12:00:00
I have put all necessary files into a single file. I want to push item into array when the user clicks on a button. Here is the content:
When I click on the button, nothing happens. Also the data is not repeated/looped and {{}}
is shown in angular which means there is a problem.
<script type=text/javascript src=angular.js ></script>
<div data-ng-app=App>
<div data-ng-controller=MyController>
<ul data-ng-repeat=one in names>
<li>{{ one.first }}</li>
</ul>
</div>
</div>
<input type=text data-ng-model=Namer.name/>
<input type=submit data-ng-click=AddName()/>
<script type=text/javascript>
var App = angular.module(App, []);
App.controller(MyController, function($scope){
$scope.names = [
{ first : Thomas},
{ first : Geferson},
{ first : Jenny},
{ first : Maria},
];
$scope.AddName = function(){
$scope.names.push({
name : $scope.Namer.name;
});
};
});
</script>
More From » angularjs