//隐藏 默认为隐藏
<input type="button" value="添加" ng-click="xianshi()"/>
//隐藏的添加的用户表单
<fieldset ng-show="xs"> | |
<legend>添加用户信息</legend> | |
姓名:<input type="text" ng-model="name1"/><br> | |
年龄:<input type="text" ng-model="age1"/><br> | |
拼音:<input type="text" ng-model="pin1"/><br> | |
职位:<input type="text" ng-model="zhiwei1"/><br> | |
<input type="button" value="保存" ng-click="add()"/> | |
</fieldset> |
//angukar代码
//控制显示/隐藏 | |
$scope.xianshi = function(){ | |
$scope.xs = true; | |
} | |
//保存 | |
$scope.add = function(){ | |
//创建对象 | |
var obj = { | |
"name": $scope.name1, | |
"age": $scope.age1, | |
"pin": $scope.pin1, | |
"zhiwei": $scope.zhiwei1 | |
}; | |
$scope.persons.push(obj); | |
//隐藏掉 | |
$scope.xs = false; | |
} |