angularjs-routing

How to keep query string parameters in URL when accessing a route of an Angular 2 app?

痴心易碎 提交于 2019-11-30 15:42:56
I have an Angular 2 test app running the latest alpha (37). There are just three routes, that look like this: @RouteConfig([ { path: '/', component: Home, as: 'home' }, { path: '/errors', component: Errors, as: 'errors' }, { path: '/about', component: About, as: 'about' } ]) I can access the routes, and when I place query string params in the URL I can read them just fine. However, a few instants after I read the parameters, I noticed that the route loads fine and the URL refreshes, removing the query string parameters. In other words, accessing this route: http://localhost:5555/errors?test

Multiple query string parameters in angularjs

泄露秘密 提交于 2019-11-30 15:19:49
问题 I'm struggling with passing and reading multiple query string parameters in a route. $routeProvider.when("/joboffers:keywords:location", { controller: "jobOffersController", templateUrl: "/App/Views/JobOffer/All.html" }); This is the search page: $scope.searchJobOffer = function () { var vm = $scope.jobOfferSearchViewModel; var path = "/joboffers?keywords=" +( vm.keywords || "") + "&location=" + (vm.location || ""); $location.path(path); } And this is the JobOffersController: 'use strict';

AngularJS: service query returning zero result

一世执手 提交于 2019-11-30 14:41:29
my app.js looks like var app = angular.module('pennytracker', [ '$strap.directives', 'ngCookies', 'categoryServices' ]); app.config(function($routeProvider) { console.log('configuring routes'); $routeProvider .when('/summary', { templateUrl: '../static/partials/summary.html'}) .when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' }) }); while my app/js/services/categories.js looks like angular.module('categoryServices', ['ngResource']). factory('Category', function($resource){ return $resource( '/categories/:categoryId', {categoryId

How to check for the existence of a module without an error being raised?

淺唱寂寞╮ 提交于 2019-11-30 10:44:26
问题 In Angular 1.2, ngRoute is a separate module so you can use other community routers like ui.router instead. I'm writing an open-source module that aims to work for multiple different router implementations. So how can I check which router is loaded or exists? I'm doing the following inside a factory in my module, but it does not work the way I expect it to: if (angular.module("ngRoute")) // Do ngRoute-specific stuff. else if (angular.module("ui.router")) // Do ui.router-specific stuff. It

AngularJS - use routeProvider “when” variables to construct templateUrl name?

岁酱吖の 提交于 2019-11-30 08:22:10
So this is what I am trying to accomplish: 'use strict'; var app = angular.module('myModule', ['ngRoute']); app.config(function($routeProvider) { $routeProvider .when('/', { redirectTo: '/pages' }) .when('/pages/:pageName', { templateUrl: 'views/pages/'+pageName+'html', controller: 'MainController' }); }); Basically, I want to use the uri to determine which template is used. Currently I get an error that pageName is not defined which I understand. What would be a different way of doing this? Thanks! templateUrl can be a function accepting object of route parameters: .when('/pages/:pageName', {

How to persist optional state parameter on browser back in ui-router?

两盒软妹~` 提交于 2019-11-30 07:46:37
问题 I'm having one parent state that has two children's state inside that I'm going to show one state based on the URL . Out of those two states one is having to parameters like param1 and param2 , I have use params option of ui-router inside state definition. State $stateProvider.state('tabs.account', { url: '/account', views: { 'content@tabs': { templateUrl: 'account.html', controller: function($scope, $stateParams) { //This params are internally used to make ajax and show some data. $scope

How to navigate one page to another page using AngularJs

半城伤御伤魂 提交于 2019-11-30 07:34:54
问题 How to navigate from one page to another page. Assume i have a login page, after entering username and password fileds while click on submit button it needs to validate and if both username and password is correct it needs to go home page. Home page content needs to display. Here i am posting code. In Browser url is changing but content is not changing. index.html <html ng-app='myApp'> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>

AngularJS and PhoneGap: $location.path causes subsequent tempateUrl lookup to fail

本秂侑毒 提交于 2019-11-30 07:10:49
问题 I'm having trouble getting path lookup to work with a AngularJS v1.2.0 and PhoneGap/Cordova Android application. I've come pretty far with html5mode(true) by setting <base href="."/> in index.html and then changing $routeProvider.when('/') to $routeProvider.when('/android_asset/www/index.html') . After that I am able to get redirectTo('login') to reach $routeProvider.when('/login') and there render templateUrl: 'static/partials/login.html' as expected. The problem I have is that if I instead

Debug route provided to routeProvider

三世轮回 提交于 2019-11-30 06:45:41
I am new to AngularJS and am attempting to debug some of my routes but I don't know how to display/view the route passed to the routeprovider. For example if my current routing is set up as follows; reportFormsApp.config(function ($routeProvider) { $routeProvider .when("/Reporting", { templateUrl: "ReportForm/rfTemplate.html", controller: "rfController" }) .when("/Dashboard", { templateUrl: "DashboardForm/dfTemplate.html", controller: "dfController" }) .when("/Analysis", { templateUrl: "AnalysisForm/afTemplate.html", controller: "afController" }) .otherwise({ redirectTo: "/Reporting" }) });

Using grunt server, how can I redirect all requests to root url?

∥☆過路亽.° 提交于 2019-11-30 06:13:11
问题 I am building my first Angular.js application and I'm using Yeoman. Yeoman uses Grunt to allow you to run a node.js connect server with the command 'grunt server'. I'm running my angular application in html5 mode. According to the angular docs, this requires a modification of the server to redirect all requests to the root of the application (index.html), since angular apps are single page ajax applications. "Using [html5] mode requires URL rewriting on server side, basically you have to