Search Posts

Category: angular-routing

Reading property resolve from angular $routeProvider error

I am trying to restrict access to some pages within the public directory using Angular routing. .when(‘/adminprofile’, { templateUrl: ‘../partials/adminprofile.html’, access: {restricted: true} }) I am trying to read what I believe is a property called access which I declared, called access ($rootScope, $location, $route, AuthService) { $rootScope.$on(‘$routeChangeStart’, function (event, next, current) { AuthService.getUserStatus() .then(function(){ if (next.access.restricted && !AuthService.isLoggedIn()){ $location.path(‘/login’); $route.reload(); } }); }); }); But what I get is this error: TypeError: next.access […]

Can I generate a ‘templateUrl’ value for every single product on json dynamically as I created the view?

i’m creating an web app using angularJs framework for javascript. The App is a store wich takes product info from json and displays it on elements. My question: can i generate a ‘templateUrl’ value for every single product on json dinamically as i created the view? var app = angular.module(“oldek_clothes”, [“ngRoute”]); var A = “i’m ‘a'”; var B = “i’m ‘b'”; var C = “i’m ‘c'”; var D = “views/store.html”; app.config(function($routeProvider) { $routeProvider .when(“/A”,{ templateUrl […]

Angular 1/ui-router – is undefined Firefox only

when I get to the state (the last state in the code) I have this error TypeError error: contact.typeRef is undefined .state({ name: ‘’, url: ‘/contact’, abstract: true, data: { skipFooter: true, cancelState: ‘project.detail.edit.headers’ }, views: { ‘[email protected]’: { component: ‘overlayContent’ } }, resolve: { contactTypes: (ContactService) => ContactService.getContactTypes() } }) .state({ name: ‘’, url: ‘/create’, abstract: true, }) .state({ name: ‘’, url: ‘/{type:string}’, params: { type: ContactTypes.physical, step: null }, component: ‘contactCreatePage’, resolve: […]

ng-view causes page to crash

Trying to replicate a simple routing example w3schools, but it keeps crashing with “RangeError: Maximum call stack size exceeded” in the console, when accessing index.html. I tried to add/remove parts of the code to isolate the problem, and the crash seems to happen at <div ng-view></div>. Why is that? The changes I made from the original example are not that drastic. Here is the code index.html <html xmlns=””> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> <script […]

Routing issue with angular directives

I’m trying to setup one of my first angular projects and am having trouble getting to grips with the routing. On page load I see the initial template that has been set by the preferencesDirective, which is great. When I click the “Change Template” button I want it to change to another template but nothing happens. If I set the template url’s in the $routeProvider to something invalid then I see a 404 error in […]

Angular rerouting to home page doesn’t work?

Here is my error: core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ‘home’ This is the code from the view.html: <div class=”container”> This is the main app; <a routerLink=”second”>Click to go to second</a> <a routerLink=”third”>Click to go to third</a> <a routerLink=”home”>Go to Home</a> <router-outlet></router-outlet> </div> And this is my array of objects which includes the path to the home and other paths. The path to the home is correct, hence […]