首先我定义一个数组:
$scope.workspaces = [{name: "Traffic Permits", state: "traffic-permits", classname: "tab_table ng-isolate-scope"}];
然后我称之为:
<a class="{{workspace.classname}}" ng-repeat="workspace in workspaces"
ui-sref="{{workspace.state}}" ui-sref-active="active">{{workspace.name}}
</a>
Seens非常直截了当。我基本上只是宣布一个菜单。但是我得到一个奇怪的错误:
TypeError: a.hashPrefix is not a function
at Object.href (http://localhost:51188/Scripts/angular-ui-router.min.js:7:11776)
at Object.y.href (http://localhost:51188/Scripts/angular-ui-router.min.js:7:19457)
at link.t (http://localhost:51188/Scripts/angular-ui-router.min.js:7:24512)
at link (http://localhost:51188/Scripts/angular-ui-router.min.js:7:24721)
at nodeLinkFn (http://localhost:51188/Scripts/angular.js:6711:13)
at compositeLinkFn (http://localhost:51188/Scripts/angular.js:6105:13)
at publicLinkFn (http://localhost:51188/Scripts/angular.js:6001:30)
at $get.boundTranscludeFn (http://localhost:51188/Scripts/angular.js:6125:21)
at controllersBoundTransclude (http://localhost:51188/Scripts/angular.js:6732:18)
at ngRepeatAction (http://localhost:51188/Scripts/angular.js:20624:15) <a class="{{workspace.classname}} ng-binding ng-scope" ng-repeat="workspace in workspaces" ui-sref="{{workspace.state}}" ui-sref-active="active">
感谢所有帮助。
angular.module('myModule').config(function ($stateProvider, $urlRouterProvider) {
//
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/traffic-permits");
//
// Now set up the states
$stateProvider
.state('traffic-permits', {
url: "/traffic-permits",
templateUrl: "/admin/permittable"
});
});
好的,我现在正在使用路由器的非限制版本。错误发生在:
url = "#" + $locationProvider.hashPrefix() + url;
错误是$locationProvider.hashPrefix() is not a function
,这可能是什么???
我在那里设置了一个断点。 hashPrefix是一个空字符串。
答案 0 :(得分:0)
哈希前缀不是属性 - 您可以使用它来设置哈希前缀。
https://docs.angularjs.org/guide/ $位置#-location服务配置
答案 1 :(得分:0)
想出来:
显然有人认为在模块配置中添加它是个好主意:$locationProvider.hashPrefix = '';
...荒谬