angularJS中的ng-if标签问题
来源:互联网 发布:男变女软件 编辑:程序博客网 时间:2024/05/03 15:27
view如下
<div ng-controller="userController"> <form> <label for="tel">账号 : </label> <input id="tel" ng-model="telephone"><br> <label for="pswd">密码 : </label> <input id="pswd" ng-model="password"><br> <input type="button" value="提交" ng-click="sendLogin()"> </form> <span ng-if="{{loading}}" >{{response}}</span></div>
controller如下
app.controller('userController',function($scope,$http){ $scope.loading = false; $scope.response = '这里显示结果'; $scope.sendLogin = function(){ var FormData = { telephone:$scope.telephone, password:$scope.password }; $http({ url:'http://120.25.205.100:88/opencart/index.php?route=moblie/login', method:"POST", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data:FormData }).success(function(response) { $scope.loading = true; $scope.response = response; }); };})
意图:
开始包含reponse的span标签隐藏,登陆请求成功后则显示返回结果,但是请求成功后span标签不出来。
debug:
监测到是ng-if指令内的参数错了。
修改:
错误
<span ng-if="{{loading}}">{{response}}</span>
正确
<span ng-if="loading">{{response}}</span>
注意,去掉了loading的双括号。
总结
暂时不知道咋总结,后面再补。
2 0
- angularJS中的ng-if标签问题
- AngularJs 中的ng-if ng-swith ng-bind-template
- 【AngularJS】解决ng-if中的ng-model值无效的问题
- 【AngularJS】解决ng-if中的ng-model值无效的问题
- js、angularjs 在ng-repeat里用ng-if隐藏某个标签
- Ng-cloak解决angularJs中的闪烁问题
- AngularJS 指令ng-if注意事项
- AngularJS之ng-if指令
- AngularJS ng-if="" 表达式
- Angularjs中的ng-repeat
- angularjs中的ng-option
- AngularJS ng-if ng-repeat下使用ng-model
- React实现Angularjs ng-show、ng-if和ng-hide
- angularjs ng-if ng-show ng-hide区别
- AngularJS的ng-show标签
- angularjs中ng-if导致闪屏
- angularjs $watch ng-include 中的变量引发的问题
- AngularJS – Conditional Display using ng-show / ng-hide, ng-if, ng-include, ng-switch
- ajax之返回值为HTML
- day8-指针数组(二级指针)、内存空间的申请、const
- 括号匹配
- 鱼眼索引控件详解之一 —— 自定义索引器
- Makefile经典教程
- angularJS中的ng-if标签问题
- Maven仓库搭建--nexus私服
- 第五届河南省赛 zzulioj 1478: Metric Matrice (模拟)
- Ubuntu下Apache中部署Django
- ORA-04098: trigger 'SYS.XDB_PI_TRIG' is invalid and failed re-validation
- fdskfjkdsjf
- Android学习笔记之动态修改xml中字符资源
- SQL 安装时报html help 1.32 update error
- 正则基础(来自网络整理)