【Web前端 - AngularJs】$location.path改变路径需要点击两次后才会跳转
来源:互联网 发布:c语言面向的是计算机 编辑:程序博客网 时间:2024/06/05 10:13
Angular的初学者。最近首次使用$location.path时,出现了一个问题,就是改变路径后
$location.path('/result')
需要点击两次后才会跳转。
解决办法:
在后面加上$scope.$apply()
$location.path('/result');$scope.$apply();
$apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries).
因为我写的那段代码是在一个第三方库(jQuery)的回调函数中执行的,所以会出现问题(具体是什么问题、是什么原因等有时间再研究~~,大家有研究过的发个链接,谢谢啦~)。
1 0
- 【Web前端 - AngularJs】$location.path改变路径需要点击两次后才会跳转
- 解决请求服务器之后使用$location.path("")跳转需点击2次按钮的问题
- angularjs路径跳转/导航
- 为何会需要点击两次
- AngularJS中$location.path() 地址栏出现”#!”问题
- UITableViewCell点击两次才跳转解决办法
- UITableViewCell点击两次才跳转解决办法
- UITableViewCell点击两次才跳转解决办法
- Button点击两次实现页面跳转
- angular 界面跳转点击两次才展示
- js 点击按钮跳转 window.location.href
- Java Web路径跳转
- Web前端JS框架AngularJS
- Web前端 Angularjs 常用网站
- Angularjs 点击文字改变背景色
- AngularJs点击状态值改变背景色
- AngularJS通过$location获取及改变当前页面的URL
- web前端学习路径
- usb
- Quartz2D基本图形绘制
- Okhttp使用简析——Android网络请求框架(一)
- 用isNaN函数判断是否是Number中的坑
- nginx日志切割
- 【Web前端 - AngularJs】$location.path改变路径需要点击两次后才会跳转
- QT编程--监听USB设备拔出和插入。
- xml解析-dom4j范例
- ASCII、Unicode、GBK和UTF-8字符编码的区别联系
- 【安装】myEclipse
- Django、MySQL开发WEB项目防止中文乱码的有效方法
- linux lsof详解
- jenkins+git+maven+centos7自动化构建部署项目(二)
- 单机使用Docker host网络安装consul和registrator