angularjs-routing

Assign multiple controller in $stateProvider.state

会有一股神秘感。 提交于 2020-01-12 04:33:05
问题 Probably this is an easy question for advanced angular users, but I did not find this issue somewhere well explained. So I was restructuring my code, when I realized, I have two controllers in a view, which is not a problem, when controller 'ACtrl' is binded by the $stateProvider and controller 'BCtrl' is binded in the view by ng-controller. But when I try to assign both of them in the $stateProvider like this: $stateProvider.state('a.view', { url: "/anurl", views: { 'menuContent': {

How to use AngularJS UI-router capture this URL with an optional parameter?

 ̄綄美尐妖づ 提交于 2020-01-07 02:55:30
问题 I'm using AngularJD ui-router to capture my URL and send two parameters from that URL to my controller. Here are my requirements: The first parameter is a mandatory integer ( id ) The second parameter is an optional string ( slug ) The two parameters are separated by a / I want it to ignore any single trailing / Currently, I'm doing this: $stateProvider.state('mystate', { url: '/mystate/{id:int}{slug:(?:/[^/]+)?}', params: { slug: {value: null} }, templateUrl: 'partials/mystate.html',

Error Module when inject 'ui.router'

岁酱吖の 提交于 2020-01-05 23:18:46
问题 When I use the ui.router, I got the error message "Error Module" and it failed to instantiate module xPlat. In html file I use the angular-ui-router verson 0.2.11 below is my injection of ui.route : (function () { 'use strict'; angular.module('xPlat', ['ui.router']) .config(function ($stateProvider) { $stateProvider .state('views', { url: '/views', templateUrl: 'views/item.html' }) .state('views.posItem', { url: '/views', templateUrl: 'views/posItem.html' }) .otherwise('/views'); }) })(); I

Angularjs routing issue, controller not loading

二次信任 提交于 2020-01-05 12:49:33
问题 I have 4 files: index.html logic.js controller.js homepage.html index.html <html ng-app="sample"> <head> <script src="angular.js"></script> </head> <body> <div> <div ng-view></div> </div> <script src="controller.js"></script> <script src="logic.js"></script> </body> </html> logic.js var myapp = angular.module('sample',[]); myapp.config(function($routeProvider) { $routeProvider .when('/', { controller:homepageCtrl, templateUrl:'homepage.html' }); }); controller.js function homepageCtrl($scope)

AngularJS $scope form attribute is undefined after ng-submit

随声附和 提交于 2020-01-05 03:09:47
问题 I'm starting with Angular and I'm still very confused with syntax and the many different ways I can code to get the same result. My latest problem is that when I submit a form, I can't get its values by doing $scope.attribute_name HTML <body ng-app="myApp"> <div ng-include src="'menu.html'"></div> <div id="container" ng-controller="MainController"> <div ui-view></div> </div> </div> login.html (included by Route) <form name="form" name='' action="" ng-submit='login($event)'> <input type="text"

Reset/Unload Controller after ChangeState (logout called) . AngularJS

最后都变了- 提交于 2020-01-02 10:29:08
问题 I am Creating an app where the user can login from FaceBook or Twitter. After login, the user is directed to some HomePage. And here, controller loads and my initial function is called which loads data specific to that user. When user clicks on Log Out. The tokens are cleared and user is directed to SignIn Page. Now without closing the app, if the user SignIn again using twitter, The user is directed to same homepage. The Scope of that controller has the same data. I know Ionic uses cache to

Reset/Unload Controller after ChangeState (logout called) . AngularJS

混江龙づ霸主 提交于 2020-01-02 10:29:05
问题 I am Creating an app where the user can login from FaceBook or Twitter. After login, the user is directed to some HomePage. And here, controller loads and my initial function is called which loads data specific to that user. When user clicks on Log Out. The tokens are cleared and user is directed to SignIn Page. Now without closing the app, if the user SignIn again using twitter, The user is directed to same homepage. The Scope of that controller has the same data. I know Ionic uses cache to

$stateProvider not loading pages as expected

百般思念 提交于 2020-01-02 07:35:31
问题 I am trying to use $stateProvider for my url routing. I thought that if I use $stateProvider , then I don't need to use $routeProvider . Is this correct? I was able to get my url routing to work with $routeProvider , but am unable to get my url routing to work with $stateProvider . Here is the code I have so far: var app = angular.module("app",['ui.state']); app.config(function($urlRouterProvider, $stateProvider, $locationProvider) { $urlRouterProvider.otherwise("/home") $stateProvider .state

$stateProvider not loading pages as expected

五迷三道 提交于 2020-01-02 07:35:13
问题 I am trying to use $stateProvider for my url routing. I thought that if I use $stateProvider , then I don't need to use $routeProvider . Is this correct? I was able to get my url routing to work with $routeProvider , but am unable to get my url routing to work with $stateProvider . Here is the code I have so far: var app = angular.module("app",['ui.state']); app.config(function($urlRouterProvider, $stateProvider, $locationProvider) { $urlRouterProvider.otherwise("/home") $stateProvider .state

angularjs $routeProvider - route not found

二次信任 提交于 2020-01-01 22:00:39
问题 I am using angularjs with requirejs. I am running into a problem where my routes are not being routed properly. It's constantly routing to /. If I change /post to /:post it hits my post route. // module/post.js define([], function () { 'use strict'; var app = angular.module('myApp.post', []) .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/post', { controller: 'PostController', template: "<div>{{page}}</div>" } ); } ]); return app; }); // main.js require.config({