Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

How to create a new view

dirkk0 edited this page Sep 5, 2014 · 1 revision

Adding a piece of static HTML code can be done via Yeoman or directly.

In Yeoman you simply enter: > yo angular:route helloworld

To do this manually, you need to create app/scripts/controller/helloworld.js which could look like this: 'use strict';

/**
 * @ngdoc function
 * @name ppnetApp.controller:HelloworldCtrl
 * @description
 * # HelloworldCtrl
 * Controller of the ppnetApp
 */
angular.module('ppnetApp')
  .controller('HelloworldCtrl', function ($scope) {
    $scope.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];
  });

Then you can create the view: app/views/helloworld.html

<p> Hello World!  </p>

Then you change the index.html by adding the controller:

<script src="scripts/controllers/helloworld.js"></script>

Then you add the route to app.js at around line 65:

.when('/helloworld', {
    templateUrl: 'views/helloworld.html',
    controller: 'HelloworldCtrl'
 })
Clone this wiki locally