当我点击任何编辑时,它会使所有联系人在angularjs中可编辑

时间:2017-01-12 21:49:46

标签: angularjs

我是Angularjs的新手。我正在使用ng-repeat并以表格格式显示信息。当我点击任何编辑时,它会使所有联系人在angularjs中可编辑。我只想编辑我点击的结尾。

dig dualstack.[endpoint] A dualstack.[endpoint] AAAA +short
(function () {
            var myApp = angular.module('myApp', ['ngRoute']);
            

            myApp.factory('myFactory', function () {	    
                var factory = {};
                factory.contacts = [{ "id": "1", "firstName": "Amy", "lastName": "Jones", "title": "Sales Representative", "Address1": "90 Street", "City": "Toronto", "State": "Ontario" }, { "id": "2", "firstName": "James", "lastName": "King", "title": "President and CEO", "Address1": "90 Street", "City": "Toronto", "State": "Ontario" }, { "id": "3", "firstName": "Ray", "lastName": "Moore", "title": "VPofSales", "Address1": "2323 Dundas St.", "City": "Mississauga", "State": "Ontario" }, { "id": "4", "firstName": "John", "lastName": "Williams", "title": "VPofEngineering", "Address1": "1343 Steels Ave.", "City": "Brampton", "State": "Ontario" }, { "id": "5", "firstName": "Joe", "lastName": "Doe", "title": "SalesRepresentative", "Address1": "3023 Parkerhill Rd.", "City": "Mississauga", "State": "Ontario" }];
                return factory;
            });

            myApp.controller('myCtrl', function ($scope, myFactory) {
                $scope.contacts = myFactory.contacts;

                $scope.contact = {};

                $scope.editContact = function (index) {
                    $scope.editId = index;
                    $scope.contact = $scope.contacts[index];
                    console.log($scope.contact);
                }

                $scope.deleteContact = function (index) {
                    $scope.contacts.splice(index, 1);
                }
                
            });
        })();

0 个答案:

没有答案