ngroute

How to display common header and footer by default in angular 2?

你离开我真会死。 提交于 2019-11-29 01:41:46
I have common header components and footer components. countries list are loading on homepage. whenever click on the country. page will get reloaded and displaying text Loading... and then header and footer displaying. but I want to display the header and footer default without waiting for full page loaded. My code here. app-routing.module.ts const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', component: HomepageComponent,}, { path: ':city', component: CountryDetailComponent }, { path: ':city/:subscategory', component: ExploreListComponent }, { path:

Angular js - check if current url matches the route (with dynamic url params)

元气小坏坏 提交于 2019-11-28 23:27:33
i'm simply doing setting this: app.config(['$routeProvider',function($routeProvider) { $routeProvider .when('/asd/:id/:slug',{ templateUrl:'views/home/index.html', controller:'Home', publicAccess:true, sessionAccess:true }); :id and :slug are dynamic params. Now i would like to check if current url matches that route ( /asd/:id/:slug ) for example the url : asd/5/it-is-a-slug which is the simplest way? i tryed this : $rootScope.$on('$routeChangeStart', function(){ console.log($route.current); }); but sometimes it returns nothing in console while switching page routes Current route allows you

Angular routes contain #! in the url instead of # [duplicate]

与世无争的帅哥 提交于 2019-11-27 17:36:00
问题 This question already has an answer here: angularjs 1.6.0 (latest now) routes not working 5 answers Recently I have noticed that when using ngRoute module in an AngularJS app, the route contains #! in the URL, which was earlier just the # . For example, www.webiste.com/#/login becomes www.website.com/#!/login I have to enable the html5Mode and also disable the requireBase which removes the base as a whole using the code, $locationProvider.html5Mode({ enabled: true, requireBase: false }); and

How to display common header and footer by default in angular 2?

假装没事ソ 提交于 2019-11-27 16:09:00
问题 I have common header components and footer components. countries list are loading on homepage. whenever click on the country. page will get reloaded and displaying text Loading... and then header and footer displaying. but I want to display the header and footer default without waiting for full page loaded. My code here. app-routing.module.ts const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', component: HomepageComponent,}, { path: ':city',

AngularJS : How do I switch views from a controller function?

元气小坏坏 提交于 2019-11-27 05:47:28
I am trying to use the ng-click feature of AngularJS to switch views. How would I go about doing this with the code below? index.html <div ng-controller="Cntrl"> <div ng-click="someFunction()"> click me <div> <div> controller.js function Cntrl ($scope) { $scope.someFunction = function(){ //code to change view? } } ganaraj In order to switch between different views, you could directly change the window.location (using the $location service!) in index.html file <div ng-controller="Cntrl"> <div ng-click="changeView('edit')"> edit </div> <div ng-click="changeView('preview')"> preview </div> </div>

Angular 1 - get current URL parameters

故事扮演 提交于 2019-11-27 03:56:25
I want to extract data from current URL and use it in controller. For example I have this url: app.dev/backend/surveys/2 Bits that I want to extract: app.dev/backend/ :type / :id Is there anything in Angular that could help me with this task ? To get parameters from URL with ngRoute . It means that you will need to include angular-route.js in your application as a dependency. More information how to do this on official ngRoute documentation . The solution for the question: // You need to add 'ngRoute' as a dependency in your app angular.module('ngApp', ['ngRoute']) .config(function (

What&#39;s the most concise way to read query parameters in AngularJS?

守給你的承諾、 提交于 2019-11-26 14:01:18
I'd like to read the values of URL query parameters using AngularJS. I'm accessing the HTML with the following URL: http://127.0.0.1:8080/test.html?target=bob As expected, location.search is "?target=bob" . For accessing the value of target , I've found various examples listed on the web, but none of them work in AngularJS 1.0.0rc10. In particular, the following are all undefined : $location.search.target $location.search['target'] $location.search()['target'] Anyone know what will work? (I'm using $location as a parameter to my controller) Update: I've posted a solution below, but I'm not

AngularJS : How do I switch views from a controller function?

时间秒杀一切 提交于 2019-11-26 11:46:22
问题 I am trying to use the ng-click feature of AngularJS to switch views. How would I go about doing this with the code below? index.html <div ng-controller=\"Cntrl\"> <div ng-click=\"someFunction()\"> click me <div> <div> controller.js function Cntrl ($scope) { $scope.someFunction = function(){ //code to change view? } } 回答1: In order to switch between different views, you could directly change the window.location (using the $location service!) in index.html file <div ng-controller="Cntrl"> <div

AngularJS routing 404 error with HTML5 mode

眉间皱痕 提交于 2019-11-26 10:57:56
I just got started with angular js , i tried routing and worked pretty well .The problem is when i refresh the page it is showing 404 error since it is checking in my actual directory rather than checking in routes. here is the complete code <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script> <body ng-app="myApp"> <base href="/" /> <a href="blue">blue</a> <a href="green">green</a> //blue.html and green.html are in same directory as

Angular 1 - get current URL parameters

依然范特西╮ 提交于 2019-11-26 10:57:45
问题 I want to extract data from current URL and use it in controller. For example I have this url: app.dev/backend/surveys/2 Bits that I want to extract: app.dev/backend/ :type / :id Is there anything in Angular that could help me with this task ? 回答1: To get parameters from URL with ngRoute . It means that you will need to include angular-route.js in your application as a dependency. More information how to do this on official ngRoute documentation. The solution for the question: // You need to