我是角度非常初学者(第一个代码)并尝试创建一个动态添加电话号码的控件,此控件包含电话类型,ISD代码和数字以及添加和删除按钮。
但是没有任何事情发生,甚至没有填写我尝试通过传递har代码数据:
// Code goes here
var EmptyGUID = -1;
var app = angular.module('PhoneApp', []);
app.controller('PhoneController12', function($scope, $http) {
debugger;
$scope.rowcounter = 1;
$scope.contacts = [];
$scope.getDate = function(date) {
return $filter('date')(date, 'MM/dd/YYYY');
}
$scope.ISDCodeList =[{"Id":-1,"Name":"Please Select"},{"Id":3,"Name":"FR +33 "},{"Id":1,"Name":"U.S.A +1 "},{"Id":2,"Name":"UK+44 "}]
$scope.BindPhoneData = function() {
console.log($('#phoneData').val())
//if ($('#phoneData').val() != "null") {
if ($('#phoneData').val() != "null" && $('#phoneData').val() != "" && $('#phoneData').val() != undefined) {
var arrData = $.parseJSON($('#phoneData').val());
if (arrData.length > 0) {
$scope.contacts = arrData
} else {
$scope.addRow();
}
} else {
$scope.addRow();
}
//$scope.getPhoneTypeList();
//$scope.getISDCodeList();
}
$scope.getPhoneTypeList();
$scope.getISDCodeList();
//, ISDCodeId: ''
$scope.addRow = function() {
$scope.rowcounter++;
$scope.contacts.push({
PhoneTypeId: 0,
ISDCodeId: 0,
PhoneNumber: '',
IsPrimaryPhone: false
});
};
$scope.BindPhoneData();
$scope.deleteRow = function(index) {
$scope.rowcounter--;
$scope.contacts.splice(index, 1);
};
function ClearForm() {
$scope.rowcounter = 1;
$scope.contacts = [];
$scope.ContactForm.$setPristine(); //here ContactForm is form name
$scope.contacts = [{
PhoneTypeId: '',
ISDCodeId: '',
PhoneNumber: '',
PhoneId: '',
IsPrimaryPhone: '',
LocationId: '',
Extension: ''
}];
}
});
请帮忙。
http://plnkr.co/edit/AIYVjpiEfX9a3PIsNbfC?p=info
由于