{"id":3018,"date":"2015-04-02T12:15:52","date_gmt":"2015-04-02T09:15:52","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=3018"},"modified":"2017-12-19T16:55:03","modified_gmt":"2017-12-19T14:55:03","slug":"angular-js-routing-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/","title":{"rendered":"Angular.js Routing Example"},"content":{"rendered":"<p>Hey geeks! Today&#8217;s example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that there isn&#8217;t yet any simple example, suitable for an Angular newbie. So, I&#8217;ll try to keep today&#8217;s post as simple as I can.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;LXJcMJZXSsqGXYW8&#8242;]<\/p>\n<h2>1. What is routing in a web app<\/h2>\n<p>Generally, web applications make use of readable URLs that describe the content that resides there. A common example could be clicking on a homepage&#8217;s link: this means that a back-end action is being executed, that results to a different view on the client-side. We often confirm similar situations after interacting in the root of a web app ( <code>\/<\/code> or <code>index.html<\/code> ), by noticing a change to the browser&#8217;s url bar.<\/p>\n<h2>2. Today&#8217;s example&#8217;s concept<\/h2>\n<p>In this example we will demonstrate a simple page navigation application. Suppose a homepage with two links and each one of them will redirect to a specified page.<\/p>\n<p><i>To get a better understanding of our concept, we &#8216;ll here implement an inline navigation. This means that we want our pages&#8217; content to be displayed inside the initial\/home page<\/i>.<\/p>\n<p>AngularJS provides the <code><a href=\"https:\/\/docs.angularjs.org\/api\/ngRoute\/directive\/ngView\" target=\"_blank\">ngView<\/a><\/code> directive to implement the fore-mentioned functionality. Specifically, <code>ngView<\/code> directive complements the <a href=\"https:\/\/docs.angularjs.org\/api\/ngRoute\/service\/$route\" target=\"_blank\">$route<\/a> service by including the rendered template of the current route into the main layout file. That is, each time the current route changes, the included view changes with it according to the configuration of the <code>$route<\/code> service.<\/p>\n<p>So, keeping in mind that our <code>index.html<\/code> contains a simple sentence with two links provided, assume we want to display the rendered templates (according to the clicked links) below that sentence; this should seem like:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;p&gt;Jump to the &lt;a href=&quot;#first&quot;&gt;first&lt;\/a&gt; or &lt;a href=&quot;#second&quot;&gt;second page&lt;\/a&gt;&lt;\/p&gt;\r\n&lt;div ng-view&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>As you see, the anchors&#8217; targets are already named, so what is left, is to configure the respective routings for Angular.<br \/>\nSo, at this point we should have a complete homepage:<\/p>\n<p><u><code>index.html<\/code><\/u><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.2\/css\/bootstrap.min.css&quot;&gt;\r\n\t&lt;script src=&quot;http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.2.26\/angular.min.js&quot;&gt;&lt;\/script&gt;\r\n\t&lt;script src=&quot;http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.2.26\/angular-route.min.js&quot;&gt;&lt;\/script&gt;\r\n\t&lt;script src=&quot;script.js&quot;&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n    \r\n&lt;body ng-app=&quot;RoutingApp&quot;&gt;\r\n\t&lt;h2&gt;AngularJS Routing Example&lt;\/h2&gt;\r\n\t&lt;p&gt;Jump to the &lt;a href=&quot;#first&quot;&gt;first&lt;\/a&gt; or &lt;a href=&quot;#second&quot;&gt;second page&lt;\/a&gt;&lt;\/p&gt;\r\n\t&lt;div ng-view&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In AngularJS, we can use the <code><a href=\"https:\/\/docs.angularjs.org\/api\/ngRoute\" target=\"_blank\">ngRoute<\/a><\/code> module for routing and deeplinking services and directives.<\/p>\n<p>Here are some important points before going on:<\/p>\n<ul>\n<li>In order to use the <code>ngRoute<\/code> module, you have to include <code>angular-route.js<\/code> to your app, which, obviously, has to be loaded, after including the <code>angular.js<\/code> script.<\/li>\n<li>The routings we need, have to be configured inside the module&#8217;s functionality, so it would be easier to define our module in a separate file, <code>script.js<\/code>.<\/li>\n<li>You have to provide same name for the <code>ng-app<\/code> tag (in html file that contains the Angular app) and the module&#8217;s definition.<\/li>\n<\/ul>\n<h3>2.1 Defining the module<\/h3>\n<p>Now, let&#8217;s define the Angular module, by providing our app&#8217;s name (as in <code>index.html<\/code>) and declaring that it depends on the <code>ngRoute<\/code> module; the last words mean that we have to &#8220;inject&#8221; <code>ngRoute<\/code> into our module ( <code>script.js<\/code> ), like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nangular.module('RoutingApp', &#x5B;'ngRoute']);\r\n<\/pre>\n<p>That&#8217;s why we had to include the <code>angular-route.js<\/code> file in our app.<br \/>\nIn order to use <code>ngRoute<\/code>, we have to call the <code>angular.config<\/code> method:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nangular.module('RoutingApp', &#x5B;'ngRoute'])\r\n    .config(function() {\r\n    \r\n     });\r\n<\/pre>\n<p>As you noticed, I also created an anonymous function inside the method, &#8217;cause, otherwise, we &#8216;ll get a script error from our browser, as <code>angular.config<\/code> method <b>requires calling it with a function<\/b>.<\/p>\n<p>From the official documentation, we can use the <code>$routeProvider<\/code> to configure Angular&#8217;s routes, so we should pass <code>$routeProvider<\/code> as a parameter in our anonymous function:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nangular.module('RoutingApp', &#x5B;'ngRoute'])\r\n    .config( &#x5B;'$routeProvider', function($routeProvider) {\r\n    \r\n     }]);\r\n<\/pre>\n<p>The <code><a href=\"https:\/\/docs.angularjs.org\/api\/ngRoute\/provider\/$routeProvider\" target=\"_blank\">$routeProvider<\/a><\/code>&#8216;s method to add a new route definition to the <code>$route<\/code> service is <code>when(path, route)<\/code>:<\/p>\n<ul>\n<li><code>path<\/code> corresponds to the requested from the client path.<\/li>\n<li><code>route<\/code> is an object parameter and contains mapping information that have to be assigned while matching the requested route (i.e. we may want to handle the newly registered route with a specific controller; <code>controller<\/code> property is responsible for this scope).<\/li>\n<\/ul>\n<p>You can read about the rest of <code>route<\/code>&#8216;s object properties, but as I fore-mentioned, here, we &#8216;ll implement a simple routing between two html files, so, I&#8217;ll only use the <code>templateUrl<\/code>.<\/p>\n<p>Please take a look at the module&#8217;s final structure:<\/p>\n<p><u><code>script.js<\/code><\/u><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nangular.module('RoutingApp', &#x5B;'ngRoute'])\r\n\t.config( &#x5B;'$routeProvider', function($routeProvider) {\r\n\t\t$routeProvider\r\n\t\t\t.when('\/first', {\r\n\t\t\t\ttemplateUrl: 'first.html'\r\n\t\t\t})\r\n\t\t\t.when('\/second', {\r\n\t\t\t\ttemplateUrl: 'second.html'\r\n\t\t\t})\r\n\t\t\t.otherwise({\r\n\t\t\t\tredirectTo: '\/'\r\n\t\t\t});\r\n\t}]);\r\n<\/pre>\n<p>Now, let me explain: the first <code>when<\/code> means that when the <code>\/first<\/code> is requested as a route, the <code>first.html<\/code> will be loaded. Same for the &#8220;second&#8221;.<\/p>\n<p>The <code>$routeProvider<\/code>&#8216;s <code>otherwise(params)<\/code> method sets route definition that will be used on route change when no other route definition is matched. Practically, this means, that if the client requests a route that isn;t defined in the <code>when<\/code> method, this method will be executed. Imagine this as a general if-else statement.<\/p>\n<p>In our case, I assume we want to display just the homepage (<code>'\/'<\/code>), when no route definition gets matched.<\/p>\n<h2>3. Demo<\/h2>\n<p><b>Firstly, please take a look at <a href=\"http:\/\/thodorisbais.blogspot.gr\/2015\/03\/how-to-solve-failed-to-execute-send-on.html\" target=\"_blank\">this post<\/a>, just to understand why you should deploy this app in a local server rather than just executing it in a browser.<\/b><\/p>\n<p>Access the web app from your local server:<\/p>\n<figure id=\"attachment_3071\" aria-describedby=\"caption-attachment-3071\" style=\"width: 407px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/initial.png\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/initial.png\" alt=\"Figure 1. Homepage of the app\" width=\"407\" height=\"177\" class=\"size-full wp-image-3071\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/initial.png 407w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/initial-300x130.png 300w\" sizes=\"(max-width: 407px) 100vw, 407px\" \/><\/a><figcaption id=\"caption-attachment-3071\" class=\"wp-caption-text\">Figure 1. Homepage of the app<\/figcaption><\/figure>\n<p>Now, click on &#8220;first&#8221;:<\/p>\n<figure id=\"attachment_3073\" aria-describedby=\"caption-attachment-3073\" style=\"width: 426px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/first.png\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/first.png\" alt=\"Figure 2. App&#039;s &quot;first&quot; page\" width=\"426\" height=\"238\" class=\"size-full wp-image-3073\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/first.png 426w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/first-300x168.png 300w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><\/a><figcaption id=\"caption-attachment-3073\" class=\"wp-caption-text\">Figure 2. App&#8217;s &#8220;first&#8221; page<\/figcaption><\/figure>\n<p>Same, for the &#8220;second&#8221;:<\/p>\n<figure id=\"attachment_3074\" aria-describedby=\"caption-attachment-3074\" style=\"width: 448px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/second.png\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/second.png\" alt=\"Figure 3. App&#039;s &quot;second&quot; page\" width=\"448\" height=\"268\" class=\"size-full wp-image-3074\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/second.png 448w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/second-300x179.png 300w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/a><figcaption id=\"caption-attachment-3074\" class=\"wp-caption-text\">Figure 3. App&#8217;s &#8220;second&#8221; page<\/figcaption><\/figure>\n<h2>4. Download the project<\/h2>\n<p>This was an example of AngularJS Routing.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here : <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/angularjs_routing.zip\"><strong>angularjs_routing.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hey geeks! Today&#8217;s example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that there isn&#8217;t yet any simple example, suitable for an Angular newbie. So, I&#8217;ll try to keep today&#8217;s post as simple as I can. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &hellip;<\/p>\n","protected":false},"author":63,"featured_media":909,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-3018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Angular.js Routing Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Hey geeks! Today&#039;s example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular.js Routing Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Hey geeks! Today&#039;s example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/toubou.techblog\/\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-02T09:15:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-19T14:55:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Thodoris Bais\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ThodorisBais\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thodoris Bais\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\"},\"author\":{\"name\":\"Thodoris Bais\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f622d6017801d9aa8131e1ae69bbdd0d\"},\"headline\":\"Angular.js Routing Example\",\"datePublished\":\"2015-04-02T09:15:52+00:00\",\"dateModified\":\"2017-12-19T14:55:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\"},\"wordCount\":1064,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"articleSection\":[\"Angular.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\",\"name\":\"Angular.js Routing Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"datePublished\":\"2015-04-02T09:15:52+00:00\",\"dateModified\":\"2017-12-19T14:55:03+00:00\",\"description\":\"Hey geeks! Today's example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Angular.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Angular.js Routing Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f622d6017801d9aa8131e1ae69bbdd0d\",\"name\":\"Thodoris Bais\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dc31ee119255c1e4aa4a4f34858284d907cce53d033584d86b0e3de46db7d0ff?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dc31ee119255c1e4aa4a4f34858284d907cce53d033584d86b0e3de46db7d0ff?s=96&d=mm&r=g\",\"caption\":\"Thodoris Bais\"},\"description\":\"Thodoris is an Oracle Certified Associate Java Programmer and currently works as a Junior Software Developer, for Intrasoft International S.A. He holds a diploma at Informatics &amp; Telecommunications Engineering and is interested in continuous development.\",\"sameAs\":[\"http:\/\/thodorisbais.blogspot.com\",\"https:\/\/www.facebook.com\/toubou.techblog\/\",\"https:\/\/instagram.com\/thodoris.bais\/\",\"https:\/\/www.linkedin.com\/pub\/thodoris-bais\/69\/6b7\/408\",\"https:\/\/x.com\/@ThodorisBais\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/thodoris-bais\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Angular.js Routing Example - Web Code Geeks - 2026","description":"Hey geeks! Today's example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/","og_locale":"en_US","og_type":"article","og_title":"Angular.js Routing Example - Web Code Geeks - 2026","og_description":"Hey geeks! Today's example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/toubou.techblog\/","article_published_time":"2015-04-02T09:15:52+00:00","article_modified_time":"2017-12-19T14:55:03+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","type":"image\/jpeg"}],"author":"Thodoris Bais","twitter_card":"summary_large_image","twitter_creator":"@ThodorisBais","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Thodoris Bais","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/"},"author":{"name":"Thodoris Bais","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f622d6017801d9aa8131e1ae69bbdd0d"},"headline":"Angular.js Routing Example","datePublished":"2015-04-02T09:15:52+00:00","dateModified":"2017-12-19T14:55:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/"},"wordCount":1064,"commentCount":7,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","articleSection":["Angular.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/","name":"Angular.js Routing Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","datePublished":"2015-04-02T09:15:52+00:00","dateModified":"2017-12-19T14:55:03+00:00","description":"Hey geeks! Today's example is related with routing in AngularJS. What I firstly found out, while searching over the net for similar resources, is that","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/angular-js-routing-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Angular.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/"},{"@type":"ListItem","position":4,"name":"Angular.js Routing Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f622d6017801d9aa8131e1ae69bbdd0d","name":"Thodoris Bais","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dc31ee119255c1e4aa4a4f34858284d907cce53d033584d86b0e3de46db7d0ff?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc31ee119255c1e4aa4a4f34858284d907cce53d033584d86b0e3de46db7d0ff?s=96&d=mm&r=g","caption":"Thodoris Bais"},"description":"Thodoris is an Oracle Certified Associate Java Programmer and currently works as a Junior Software Developer, for Intrasoft International S.A. He holds a diploma at Informatics &amp; Telecommunications Engineering and is interested in continuous development.","sameAs":["http:\/\/thodorisbais.blogspot.com","https:\/\/www.facebook.com\/toubou.techblog\/","https:\/\/instagram.com\/thodoris.bais\/","https:\/\/www.linkedin.com\/pub\/thodoris-bais\/69\/6b7\/408","https:\/\/x.com\/@ThodorisBais"],"url":"https:\/\/www.webcodegeeks.com\/author\/thodoris-bais\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/3018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=3018"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/3018\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/909"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=3018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=3018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=3018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}