angularjs-routing

AngularJs routing with Asp.Net Mvc

烈酒焚心 提交于 2019-11-28 01:49:27
问题 I'm trying to build a SPA with Asp.Net MVC. for this I'm using angularJs routing . This is my project hierarchy. My Layout.cshtl code <html lang="en" ng-app="ProjectTrackingModule"> <head> <script src="~/Scripts/jquery-2.1.0.min.js"></script> <script src="~/Scripts/angular.min.js"></script> <script src="~/Scripts/angular-route.min.js"></script> <script src="~/Scripts/app.js"></script> </head> <body> <a href="#Home">Home</a> <a href="#Projects">Projects</a> <div ng‐view style="margin‐left: 10%

Simple Angular $routeProvider resolve test. What is wrong with this code?

醉酒当歌 提交于 2019-11-28 01:11:38
问题 I have created a simple Angular JS $routeProvider resolve test application. It gives the following error: Error: Unknown provider: dataProvider <- data I would appreciate it if someone could identify where I have gone wrong. index.html <!DOCTYPE html> <html ng-app="ResolveTest"> <head> <title>Resolve Test</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.js"> </script> <script src="ResolveTest.js"></script> </head> <body ng-controller="ResolveCtrl"> <div ng

AngularJS UI Router $state reload child state only

偶尔善良 提交于 2019-11-27 20:26:59
I am using UI router for tabs of a main menu as well as for links within one of the states (users). The users state has a list of users and when a user is clicked, I want to reload the child state only, but it is reloading both the child state and the parent state (users). Here's my code: app.config(function ($stateProvider, $locationProvider, $urlRouterProvider) { $urlRouterProvider.otherwise("/"); $locationProvider.html5Mode(true); $stateProvider .state('home', { abstract: true, template: '<div ui-view=""></div>', controller: 'HomeController as homeCtrl' }) .state('users', { parent: 'home',

angularjs route unit testing

帅比萌擦擦* 提交于 2019-11-27 17:36:27
As we see here in http://docs.angularjs.org/tutorial/step_07 , angular.module('phonecat', []). config(['$routeProvider', function($routeProvider) { $routeProvider. when('/phones', {templateUrl: 'partials/phone-list.html', controller: PhoneListCtrl}). when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}). otherwise({redirectTo: '/phones'}); }]); routing test is suggested to be done with e2e test, it('should redirect index.html to index.html#/phones', function() { browser().navigateTo('../../app/index.html'); expect(browser().location().url()).toBe('

Is there a way to preload templates when using AngularJS routing?

心已入冬 提交于 2019-11-27 17:26:56
After the Angular app is loaded I need some of the templates to be available offline. Something like this would be ideal: $routeProvider .when('/p1', { controller: controller1, templateUrl: 'Template1.html', preload: true }) There is a template cache service : $templateCache which can be used to preload templates in a javascript module. For example, taken from the docs: var myApp = angular.module('myApp', []); myApp.run(function($templateCache) { $templateCache.put('templateId.html', 'This is the content of the template'); }); There is even a grunt task to pre-generate a javascript module from

Updating URL in Angular JS without re-rendering view

女生的网名这么多〃 提交于 2019-11-27 17:09:22
I'm building a dashboard system in AngularJS and I'm running into an issue with setting the url via $location.path In our dashboard, we have a bunch of widgets. Each shows a larger maximized view when you click on it. We are trying to setup deep linking to allow users to link to a dashboard with a widget maximized. Currently, we have 2 routes that look like /dashboard/:dashboardId and /dashboard/:dashboardId/:maximizedWidgetId When a user maximizes a widget, we update the url using $location.path , but this is causing the view to re-render. Since we have all of the data, we don't want to

AngularJS redirect a route only on browser's back button

雨燕双飞 提交于 2019-11-27 17:03:45
问题 In my AngularJS application I'm redirecting the route to a specific page when the user isn't logged. To do that I'm using a variable on $rootScope . Now I would like to prevent the browser's back button when the user is logged. I would like to redirect it to a specific page (the registration view). The problem is I don't know if there's a back button event . My code is: angular.module('myApp',[...] //Route configurations }]) .run(function($rootScope, $location){ $rootScope.$on('

AngularJS redirect without pushing a history state

社会主义新天地 提交于 2019-11-27 12:46:10
问题 I'm working on an AngularJS app that has a catch all route (eg, .when('/:slug', {...) ) which is necessary to support legacy url formats from a previous (non-angular) version of the app. The controller that responds to the catch all tries pulling a related object, and, if not found, redirects to a 404 page using the $location.path method. This works at getting the user to the 404 page, but when the user hits back in their browser it takes them back to the page that forced them to the 404 page

how to pass querystring in angular routes?

与世无争的帅哥 提交于 2019-11-27 12:37:10
I am working with AngularJS routes, and am trying to see how to work with query strings (for example, url.com?key=value ). Angular doesn't understand the route which contains key-value pair for the same name albums : angular.module('myApp', ['myApp.directives', 'myApp.services']).config( ['$routeProvider', function($routeProvider) { $routeProvider. when('/albums', {templateUrl: 'albums.html', controller: albumsCtrl}). when('/albums?:album_id', {templateUrl: 'album_images.html', controller: albumsCtrl}). otherwise({redirectTo: '/home'}); }], ['$locationProvider', function($locationProvider) {

How to call a function in AngularJs when route matches?

微笑、不失礼 提交于 2019-11-27 12:34:23
问题 $routeProvider.when('/ticket', { controller: TicketController, templateUrl: Routing.generate('ticket_list') }); displays a simple list where each entry is selectable. However on select no extra view is loaded. Every thing is in ticket_lost template . The template has some hidden fields that are revealed when entry is clicked. I can define which entry is selected internally by setting selectedTicket = 1; So when there is a route like /ticket/1 I want to call a function that sets selectedTicket