angular-ui-router

Attach data dynamically to state.go function and retrieve in resolve property

旧街凉风 提交于 2019-12-11 09:46:57
问题 I have a parent state: .state('schoolyears', { url: '/schoolyears', views: { 'menu@': { template: '<h1>Start your schoolyear action...</h1>' }, 'content@': { templateUrl: "../views/schoolyear/schoolyears.html", resolve: { schoolyears: function (schoolyearService) { return schoolyearService.getSchoolyears(); } }, controller: 'SchoolyearsController' } } }) .state('schoolyears.selected', { url: '/:id' }) and a child state: .state('schoolyears.selected.dates.day', { url: '/day/:year-:month-:day',

Reinitialize Controller every time when visiting View - Ionic Framework

五迷三道 提交于 2019-12-11 09:45:03
问题 Hi i'm having two views in my app with two controllers assigned to each. Here i need to reinitialize the controller every time when ever i navigate to particular view. Angular Script: .state('app.pnrlist', { url: "/pnrlist", views: { 'menuContent': { templateUrl: "templates/test.html", controller: "testControl", reload: true } }, reload:true }) .state('app.home', { url: "/home", views: { 'menuContent': { templateUrl: "templates/home.html", controller:"homeControl", reload:true } }, reload

Angular UI-Router $urlRouterProvider.when handler result ignored by $state

核能气质少年 提交于 2019-12-11 09:44:27
问题 I added a when() method to set/validate a route prefix, which looks something like this: $urlRouterProvider.when(/[a-z]{2}-[a-z]{2}/, [ '$match','myValidatorSrv', function($match, myValidatorSrv) { if ( myValidatorSrv.validate($match[0]) ) return true; // … return $match.input.replace($match[0],'en-us'); } ]); $urlRouterProvider.when(/(?![a-z]{2}-[a-z]{2})/, [ '$match','myValidatorSrv', function($match, myValidatorSrv) { // … return $match.input.replace('/', '/en-us/'); } ]); The re-writing

Change ui-view template without changing URL

こ雲淡風輕ζ 提交于 2019-12-11 09:43:59
问题 I have the following states configuration (simplified): $stateProvider .state( 'showitem', { url: '/item/{id}', templateUrl: 'showitem.html', controller: 'MyCtrl' } ) .state( 'notFound', { url: '^*path', templateUrl: '404.html'} ); When I enter /badurl , 404 error is shown as expected. When I enter /item/123 , the application's API is being queried for item with specified identifier. It returns item data on success or 404 HTTP header if the item could not be found. In order to detect such

angular-ui-router views and controllers are not loading after upgrading to angular 1.3

為{幸葍}努か 提交于 2019-12-11 09:38:34
问题 after I did the update to angular 1.3 I'm not able to reach the controllers and views, they simply doesn't load. the states in my root works perfectly, this is my app.js $stateProvider.state("root", { url: '', abstract: true, views: { 'footer@': { templateUrl: "/partial/footer/footer.html", }, 'header@': { templateUrl: "/partial/header/header.html", } } }).state('root.home', { url: '/index', views: { 'container@': { templateUrl: '/partial/index/index.html', controller: 'IndexCtrl' } } } )

ui-router— having a route's URL share the same level as another state with $stateParams?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 09:22:59
问题 I'd like to do something like this in my application, where the same level of the URL hits the either the baz state, that absolutely named, or the biz state that takes a parameter. angular.module('foo') .config(function($stateProvider){ $stateProvider .state('baz', { url: '/baz', templateUrl: '/templates/baz.html' }) .state('biz', { url: '/:biz', templateUrl: '/templates/biz.html', resolve: { biz: function($stateParams){ // resolve whatever $stateParams.biz should be } } }) }) However, what's

How to $compile angular template to make it work in multiple controllers with aliases?

一曲冷凌霜 提交于 2019-12-11 08:55:13
问题 I have a custom directive that simply $compiles a template into another. .directive('staticInclude', function($http, $templateCache, $compile) { return function(scope, element, attrs) { var templatePath = attrs.staticInclude; // $http.get(templatePath, { cache: $templateCache }).success(function(response) { var contents = element.html(response).contents(); $compile(contents)(scope); }); }; }); I use it like: <div static-include="components/campaign/details.html"></div> Because I'm using

Angular.js UI-Router templates are not loading

不羁岁月 提交于 2019-12-11 08:48:58
问题 I'm making a simple Angular Website. For Routing I'm using Angular-ui-router. When I click on Home, About the templates are not loading whereas when I click on Contact the template loads perfectly. Can someone please help me where I made a mistake.Here is the link for plunker > https://plnkr.co/edit/8LlDl08JVbQKiD5eWEah?p=preview 回答1: you are using for contact home and about always same module 'homeModel' angular.module('homeModel', []) the contact ist the last one and overwrites it <script

Scope inheritance fails with multiple-named views?

送分小仙女□ 提交于 2019-12-11 08:42:11
问题 It breaks when moving from (Plnkr): .state('home', {url: '/home', template: '<pre>{{parentProp}}</pre>', controller: function ($scope) {$scope.parentProp = ['home'];}}) To (Plnkr): .state('home', {url: '/home', views: {'': {template: '<pre>{{parentProp}}</pre>'}}, controller: function ($scope) {$scope.parentProp = ['home'];}})` Specifically I have a 'sidebar' state I want to add as a secondary state to 'home' . 回答1: The view needs its own controller: .state('home', {url: '/home', views: {'':

Angular routing appears to be preventing scrolling

孤街醉人 提交于 2019-12-11 07:35:19
问题 I have set up an angular app with routing and the problem I've run into is that the individual components seem unable to scroll. In my index.html file, I have <app-root><div class="loading"></div></app-root> Then in my app.component.html, I have <router-outlet></router-outlet> Then I have my various components. I have found that I get scrolling functions if I replace the given code with a long paragraph in either app.component.html or index.html but I get no scrolling if I place the paragraph