使用嵌套路径的角度“获得”无法解决…从状态…“错误
发布时间:2020-12-17 08:26:13 所属栏目:安全 来源:网络整理
导读:我很喜欢angularjs,我想为我的应用程序使用嵌套的ui-route。一些代码片段… profile.html div class="row"div class="dl-horizontal" id="information" div class="col-md-8 col-md-offset-2" !-- edit button -- div style="margin-bottom: 15px" div clas
我很喜欢angularjs,我想为我的应用程序使用嵌套的ui-route。一些代码片段…
profile.html <div class="row"> <div class="dl-horizontal" id="information"> <div class="col-md-8 col-md-offset-2"> <!-- edit button --> <div style="margin-bottom: 15px"> <div class="button" style="margin-top:5px" style="float:left"> <button type="button" class="btn btn-primary" ui-sref="edit_profile" ng-click="populate()"><span class="glyphicon glyphicon-pencil"></span> Edit Profile</button> </div> </div> client_UI.js //object for routing var route = angular.module('route',["ui.router"]) // configure the routing route.config(function($stateProvider,$urlRouterProvider,$locationProvider) { // send to profile page $urlRouterProvider.otherwise("/profile"); $stateProvider // route for personal info .state('profile',{ url: "/profile",templateUrl : "profile_area/profile.html",controller : 'profileController' }) edit.html <script src="Scripts/angular-ui-bootstrap.js"></script> <!-- title --> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h2 class="modal-title"> Editing Profile</h2> </div> <div class="modal-body"> <form role="form" id="myForm"> <!-- Name --> <div class="panel panel-default"> <div class="panel-body"> <div class="form-group"> <label for="name">Name </label> <input placeholder="{{infos.Name}}" id="name" type="text" ng-model="name"> </div> profile.js //object for routing var route = angular.module('route',$locationProvider) { $stateProvider //route for edit page .state('edit_profile',{ url: "/edit_profile",templateURL : "edit/edit_profile.html",controller : 'editController' }) }); route.controller('editController' ["$scope","$resource",function($scope,$resource) { // resource objects var profile = $resource($scope.apicall + "/api/userprofile/",{Userid:$scope.userid},{'post':{method: 'POST'}}); var edit = new profile(); 这是view(index.html)… <!-- route veiw --> <div class="container" id="route" style="width:90%"> <div ui-view></div> </div> <!-- Footer --> <footer></footer> 我从控制台得到一个错误,表示无法从状态“个人资料”中解析“edit_profile”,而edit.html应该是profile.html的子级状态。我正在使用ui路由在angularjs。我想要点击profile.html中的一个按钮,将其状态更改为edit_profile,并将显示在index.html的ui视图中。关于如何解决这个问题的任何建议,还是有另一个简单的方法呢?
在这种情况下,有角度通知我们:我根本无法找到状态edit_profile。我创造了工作
example here
原因其实就是我们真的要加载2个js文件: > profile.js 它们都必须被加载,但是它们都不能声明同一个模块: var route = angular.module('route',["ui.router"]) 其中一个必须是不同的,或者只是不声明,而是消耗模块: // client_UI.js var route = angular.module('client_ui',["ui.router"]) // profile.js var route = angular.module('route',["ui.router","client_ui"]) 或者两者都可以在同一个模块中: // client_UI.js var route = angular.module('route',["ui.router"]) // profile.js var route = angular.module('route') 检查所有工作here (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- angular2(2.0.0-beta.3)路由url无法正常工作
- angularjs – 重新打开并将依赖项添加到已经引导的应用程序
- 在Angularjs中弹出一个鼠标悬停的div
- Hacking with Angular:如何在深层嵌套ngRepeat中获取不同层
- 条纹元素与角2
- CXF 做 webservice 简单例子demo
- fat jar 解决webservice客户端打包jar文件 bat批处理运行
- Webservice Timeout,HTTP Server Return "500 Interna
- 在vim中编辑latex:如何将文本更改为数学模式
- 使用AutoCompleteExtender(自动完成下拉菜单)实例