angularjs - 单击链接时Angularjs ui-view路由不起作用
问题描述
当我点击 lick 时,我在这里使用 Angular ui-routing 功能 url 在 url bar 中扩展 像这样
AngularCtrl 是
var app = angular.module('MyApp', ['ui.router'])
app.config(['$qProvider', '$stateProvider', function ($qProvider, $stateProvider) {
$qProvider.errorOnUnhandledRejections(false);
var Custstate = {
name: 'Customer',
url: 'Views/Customer/Customer.html',
}
$stateProvider.state(Custstate);
}])
ui-view 是
<a ui-sref="Customer" ui-sref-active="active">Customer</a>
<ui-view></ui-view>
解决方案
在这样的配置注册状态。
var routerApp = angular.module('MyApp', ['ui.router']);
routerApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('Customer', {
url: '/Customer',
templateUrl: 'Views/Customer/Customer.html'
});
});
有关更多详细信息,请参阅https://scotch.io/tutorials/angular-routing-using-ui-router。
推荐阅读
- javascript - Javascript 最大 blob 大小检测
- progressive-web-apps - PWA 格式化本地存储
- wordpress - 为什么我的锚链接没有附加到涉及 WordPress 短代码的按钮上?
- validation - 无法使用 mysql 7 中的复杂检查约束案例验证数据
- java - 找到完美直角三角形的另外两个点
- python - 在 while 循环中使用计数器时 Turtle 模块崩溃
- python - 为什么我在类型注释上收到 SyntaxError?
- json - 使用 serde Rust 将数据从记录转置到没有中间结构的列
- r - Efficient recoding of numeric variables into a factor in a data.frame
- javascript - 使用 Javascript 运行目录中的另一个文件