- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的网址中间出现一个奇怪的#,例如,如果我尝试访问 localhost:8080,我的 AngularJS 应用程序正在运行,我会被重定向到 http://localhost:8080/#/home 。我不明白这个 # 来自哪里,但我怀疑它与我在 $stateProvider 中定义的 URL 有关。
这是 $stateProvider 代码:
//STATE HANDLER
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
app.config([
'$stateProvider',
'$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('newAlarm', {
url: '/newAlarm',
views: {
'': {templateUrl: '/templates/newAlarmPage.html'},
'header@newAlarm':{templateUrl: '/templates/header.html'},
'newAlarmForm@newAlarm':{templateUrl: '/templates/newAlarmForm.html'}
},
controller: 'NewScheduleCtrl'
})
//to be changed
.state('home', {
url: '/home',
views: {
'': {templateUrl: '/templates/homePage.html'},
'header@home':{templateUrl: '/templates/header.html'}
},
controller: ''
});
//end of to be changed
$urlRouterProvider.otherwise('home');
}]);
有什么想法吗?
最佳答案
摘自维基百科文章single page applications :
The page does not reload at any point in the process, nor does control transfer to another page, although the location hash can be used to provide the perception and navigability of separate logical pages in the application
使用哈希使 Angular(和其他 SPA 框架)能够路由 URL,而无需重新加载页面。
相关问题:
关于javascript - 从 angularJS $stateProvider 获取 URL 中的 #,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35043399/
我正在尝试将 $stateProvider 用于我的 url 路由。我想如果我使用$stateProvider,那么我就不需要使用$routeProvider了。这个对吗?我能够让我的 url 路由与
好吧,这个问题有点长,但我觉得我已经尝试了一切,所以如果可以的话,我希望你能帮助我:) 所以基本上我的系统有两种用户类型:Admin 和 Client 这些类型绑定(bind)到模板 tpl/app.
我是 Angular JS 的初学者,最近尝试了 $stateProvider,引用了一个教程-eggHead。从下面找到代码: 我没有得到正确的回应。 index.html
我真的搞不懂为什么这个标记不能识别我的 $stateProvider? Uncaught Error: [$injector:modulerr] Failed to instantiate modul
我一直在寻找这个难题的好答案,无论是routeProvider还是不行。 似乎$ routeProvider即将终止,并替换为$ stateProvider,不幸的是,我不知道此语句的准确性,而且st
我只是 angularjs 的初学者。我在下面的测试项目中没有看到任何错误和结果。索引.html User Auth
使用 angular-ui-router,如何使用 otherwise method上$stateProvider或者我该如何使用它? 最佳答案 您不能仅使用$stateProvider。 您需要注入
考虑这段代码: bank.config(function($stateProvider) { $stateProvider .state('main.bank', { url:
在我的主 index.html 文件中,我有以下简单标记... 在我的 app.js 中,我使用 $stateProvider 创建路由,以便我可以显示某些页面... app.confi
我刚开始更改其他人的一些代码,并尝试添加一个带有 Controller 的简单 html。我的问题是,我的 html 不会加载,如果我导航到它.. 系统只会显示:正在加载... 这是 html: t
我刚刚开始迁移到 AngularJS,并且 angular-ui/ui-router 中的 $stateProvider 已经出现问题框架。这是我到目前为止所拥有的: angular .mod
我有一个看起来像这样的 View : Data Package Management
我只是有 Angular 路线的问题。我有一个具有 4 个不同 View 的单页应用程序。我正在使用 $stateProvider 的 ui.router。主视图在路线上:https://testsi
我的页面上有如下按钮: 单击后我想使用 ui-sref 更改状态。我目前处于/status 状态,并且我想进入/status/{maId} 状态。 这是我的routes.js (functi
.controller('myCtrl', function($scope,$localstorage,$stateProvider, $urlRouterProvider) { $scope.g
我在我的应用程序中使用 angularJs 版本 1.4.5 和 angular-ui-router 版本 0.2.18。我注意到我的解析函数针对某个状态执行了两次。 我也尝试过使用更新的 angul
我目前正在阅读一个基于 AngularJS 1.4.8 的应用程序,该应用程序使用 AngularUI Router 0.2.15。 我注意到此应用程序有时使用依赖项 $state,有时使用依赖项 $
我得到了一个使用标准 $routeProvider 进行路由的当前 angularjs 应用程序。我打算将应用程序的一部分 $stateProvider 用作向导。 我这样声明父状态“Modal”和子
WikiApp.config(function config($stateProvider, $urlRouterProvider) { $stateProvider .state('
所以我在这个 Angular SPA 上工作了一段时间,遇到了一个有趣的现象,我希望有人能帮我弄清楚。 Safari 会给我 Did not parse stylesheet at 'http://l
我是一名优秀的程序员,十分优秀!