Mittwoch, 18. Mai, 2016
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Finishing Angular TODO application and deploying to production 107<br />
1 app.config(['$locationProvider', function($locationProvider) {<br />
2 $locationProvider.hashPrefix('!');<br />
3 }<br />
4 ]);<br />
Build me some routes<br />
In the public/example folder create a folder named config and inside it a file example.client.routes.js<br />
with the following content:<br />
1 angular.module('example').config(['$routeProvider',<br />
2 function($routeProvider) {<br />
3 $routeProvider.<br />
4 when('/', {<br />
5 templateUrl: 'example/views/example.client.view.html'<br />
6 }).<br />
7 otherwise({<br />
8 redirectTo: '/'<br />
9 });<br />
10 }<br />
11 ]);<br />
The previous mumbo jumbo explained in quick rundown:<br />
• with angular.module(‘example’) method you fetched the example module and<br />
• executed the config() method in which you applied the aforementioned dependency injection<br />
to inject the $routeProvider (available from ngRoute module),<br />
• where you used his when() method to define a new route along with the route URL and the<br />
template URL<br />
• otherwise() method defines the behavior of the router when the user navigates to an<br />
undefined URL<br />
ngRoute module also comes with the ng-view directive which tells the AngularJS router which<br />
DOM element to use to render the routing views. In order to use this, add the following line to your<br />
app/views/index.ejs file: