각도를 배우려고합니다. 입력을 만들고 싶습니다. 데이터를 입력하면 데이터가 같은 페이지에 나타납니다. 내 로컬 (내 컴퓨터)의 작업에이각도 데이터 입력
<body ng-controller="nameCtrl">
<div class="body container">
<ul>
<li ng-repeat="name in names">{{name}} <!-- place for all username -->
<a href="" ng-click="removename(name)">remove</a> <!-- button remove -->
</li>
</ul>
<form action="" ng-submit="addName()">
<label for="">first name :</label>
<input type="text" ng-model="firstname">
<label for="">last name :</label>
<input type="text" ng-model="lastname">
<input type="submit" value="add"> <!-- button add -->
</form>
</div>
</body>
var myApp = angular.module('myApp', []);
myApp.controller('nameCtrl',function($scope){
// ARRAY
$scope.names=['firstname1 lastname1','firstname2 lastname2','firstname3 lastname3'];
// ADD NAME
$scope.addName= function(){
$scope.names.push($scope.firstname +' '+ $scope.lastname);
$scope.firstname="";
$scope.lastname="";
};
//REMOVENAME
$scope.removename= function(name){
var i= $scope.names.indexOf(name);
$scope.names.splice(i,1);
};
});
같은 코드,하지만 난 jsfiddle으로 테스트 할 때. 이 코드는 온라인에서 작동 할 수 있다는 것을 의미합니다. 여기에 예를 : 미안, jsfiddle에 태그 html
을 가지고 잊어 https://jsfiddle.net/hec57h2a/
여기 링크입니다. –