javascript - AngularJs ngRoutes 不工作

标签 javascript angularjs routes ngroute hashbang

我添加了这个链接标签<a href="#/pendingJobs">并且在Js中写了这种类型的when函数

.when("/pendingJobs", {
    templateUrl : 'jobsPending.php',
    controller : 'appCtrl'
})

但是当我单击链接时,它会创建一个像 /#%2FpendingJobs 这样的网址由于此链接问题.when("/pendingJobs"不工作..

最佳答案

前缀的默认值更改为“!”。

我不知道您使用的是哪个 Angular 版本。

但它应该适用于此更改。将 hashPrefix 更改为 ''

.config(function($locationProvider) {
  $locationProvider.html5Mode(false).hashPrefix('');
})

更多信息请点击 https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52

关于javascript - AngularJs ngRoutes 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43295578/

相关文章:

javascript - Angular Controller 中的 jquery focusin 和 focusout

angularjs - 降级 Angular js 的所有 Angular 组件的优雅方法

javascript - 在单独的文件中重写prototype.js中的getOffsetParent()函数

javascript - 多个 HTML DOM - 解析和传输数据

angularjs - "$onInit"是比 "activate"更有效的方法来激活 angularJS 中的 "controller"吗?

javascript - 如何在 Angular 工厂内定义ngModel?

ruby-on-rails - 将 Rails 路线限制为 Action

symfony - 如何修复 Symfony 3.4 上的 'Uncaught PHP Exception Twig_Error_Loader: Unable to find template'?

c++ - 在类数据结构中存储地址和路由信息

javascript - HTML 页面呈现 - 通过 Javascript 调整大小进行的更正感觉有点不和谐