Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HTML Page With AngularJS Routing Features

Featured Replies

I am very new to AngularJS and planning to get a web page using Angular Routing in home page contents. I want to get a demo page but can't find any on the internet.

 

Can somebody suggest some templates having content using with Angular Routing ? That will help me to get startup.

 

thanks you!

Bit of a late reply, so I hope you're still checking this. If you're just getting into Angular definitely check out Scotch.io they have great tutorials. So, routing with Angular is actually really intuitive if you are familiar with an MVC architecture, it's a lot more simple than achieving the same thing with AJAX calls. For example:

 

This would be the simplest file structure to make a really basic one page app:

 

- script.js: Put all your angular code here.

- index.html: Your main page where the views will be injected.

- home.htm: The last three are your views.

- page2.htm

- page3.htm

 

So, to start with inside index.html, set up your basic page structure and things that'll be present across your app i.e. your navigation and that kind of thing. Make sure when you are linking to a view to put a # in front of the URL i.e. href="#page2"

 

- Make sure to define your angular app in the opening HTML tag.

- And set the default controller you want inside the body tag, other controllers will be dealt with by Angular's routing service, seen below.

<!DOCTYPE html>
<!--Define our angular app-->
<html ng-app="myApp">
<head>

<!--Load Angular-->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>
  <script>script.js</script>
</head>

<!--Set the default controller-->
<body ng-controller="homeController">
  <header>
    <nav>
      <ul>
        <li><a href="#home.htm"</li>
        <li><a href="#page1.htm"</li>
        <li><a href="#page2.htm"</li>
      </ul>
   </nav>
  </header>


  <div id="view">

  <!--Inject views here-->
  <div ng-view></div>

  </div>
</body>

Inside script.js you'll need to create the Angular module and controllers. Let me explain what's going on here:

 

- First you create the module and name it something more appropriate than myApp hopefully and include ngRoute for all the view injecting.

- Next you start to configure the routing using angular's $routeProvider. Specifying when a specific URL is accessed which template (the view file) and which controller to use.

- At the bottom we define a controller for each page and set a scope variable of scope.message equal to something for testing purposes.

//Create your module including the ngRoute.
var myApp = angular.module('myApp', ['ngRoute']);

//Start to configure your routes.
myApp.config(function($routeProvider){
  $routeProvider

    .when('/', {
      templateURL: 'home.htm',
      controller: 'homeController'
    )}

    .when('/page1', {
      templateURL: 'page1.htm',
      controller: 'page1Controller'
    )}

    .when('/page2', {
      templateURL: 'page2.htm',
      controller: 'page2Controller'
    )}
});

//Create a controller for each view:
myApp.controller('homeController', function($scope) {
    $scope.message = 'Home page!';
});

myApp.controller('page1Controller', function($scope) {
    $scope.message = 'Another page!';
});

myApp.controller('page2Controller', function($scope) {
    $scope.message = 'And one more...';
});

Finally you just need to make your views. For example:

 

- {{ message }} will print the value of the scope variable message, in this case "Another Page!"

<!--page1.htm-->
<h1>This is the view rendered for page 1!</h1>

<p>{{ message }}</p>
  • 2 months later...

thanks for your support. I will try it

 

I should probably note that the solution I provided is outdated, it uses AngularJS. The more recent framework is just known as Angular. If you're going to start going down an Angular route, it'd probably be better to focus on the more recent framework. The following tutorial should help:

 

https://scotch.io/tutorials/routing-angular-2-single-page-apps-with-the-component-router

 

I would still give Angular a chance, in terms of job opportunities it is still miles ahead of React and has a bigger community to get support from (a result of being an older technology). A lot of the problems have been addressed in the move from AngularJS - Angular and although it's nowhere near a perfect tool (neither is React) it's still a strong tool to have in your arsenal.

 

If you haven't invested much time yet into Angular then ditch it and look at something like React :)

 

I reckon you should check out this article, give it a chance ;)

 

http://blog.techmagic.co/angular-2-vs-react-what-to-chose-in-2017/

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.