这是我对angularJS应用程序的配置。
var regex =/^\d+$/;
if (regex.test(val)) {
alert('value is ok, use it');
}else{
alert('Invalid number; must be eleven digits');
Phone.focus()
return false}
问题是,当我输入我的域名时,例如example.com,我希望它转换为http://example.com/#/Home,但有时(10个中有6个),example.com不会更改为http://example.com/#/Home ,因此应用程序无法正确加载。
一旦我点击卸载的应用程序中的任何链接,它就会开始正常工作。
如何确保每次页面正确加载。
答案 0 :(得分:0)
而不是直接添加
$urlRouterProvider.otherwise("/Home");
尝试使用以下路线
$urlRouterProvider
.when('/', function ($state) {
$state.go('Home');
}).otherwise('/Home');
答案 1 :(得分:0)
以下是我认为可以解决您的问题:http://niclassahlin.com/2014/05/31/kickstarting-angular-ui-router/
app.run(['$state', function ($state) {}])
基本上,您需要在应用运行时启动路由器,确保初始化其他路由。不知道为什么你当前的应用程序会偶尔正确地路由而不会看到完整的代码。