无法匹配AngularJS中的路由
Unable to match route in AngularJS
我的app.js
:中有以下代码
var myApp = angular.module('myApp', ['ngRoute'])
myApp.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/products', {
templateUrl: '/angularjs/public/angular/views/product.html'
}).
otherwise({
templateUrl: '/angularjs/public/angular/views/home.html'
});
$locationProvider.html5Mode(true);
}]);
当我在http://localhost/angularjs/public
回家时,.otherwise
正确启动。
如果我转到http://localhost/angularjs/public/products
,什么都不会发生,或者更准确地说,我相信.otherwise
会再次被调用,因为它显示的是home.html
视图。batarang's
控制台中也没有抛出任何错误。
可能是什么问题?
您需要在路线中向产品段塞添加"public"
when('public/products', {
templateUrl: '/angularjs/public/angular/views/product.html'
}).
相关文章:
- 在AngularJS应用程序中使用封装指令和路由的推荐方式是什么
- AngularJS ui路由器html5模式中断路由
- 路由不'我不在AngularJS工作
- 在angularjs中动态路由url路径
- AngularJS路由没有'不起作用
- AngularJS路由在初次点击时没有加载ng模板
- Angularjs:ui路由嵌套状态下的绑定不起作用
- AngularJS路由服务器端支持(NodeJS+express)
- AngularJs 多个布局用于不同的路由
- 延迟 AngularJS 路由更改,直到加载模型以防止闪烁
- AngularJS 路由功能不起作用
- AngularJs 路由名称未更新
- 防止谷歌索引AngularJS路由
- Angularjs:路由后如何调用控制器函数
- 在 AngularJS 路由中使用常量
- AngularJS-有条件地为路由设置控制器
- Angularjs UI视图和Rails服务器端模板路由
- AngularJS路由未绑定控制器
- 在路由 angularjs/expressjs 之间传递数据
- 基于JSON响应的动态路由angularJS