Created
June 21, 2016 16:07
-
-
Save navarroaxel/38eb58f43dc9302950df87bd8c641663 to your computer and use it in GitHub Desktop.
Angular UI Router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Title</title> | |
| </head> | |
| <body ng-app="app"> | |
| <main ui-view></main> | |
| <script src="angular/angular.min.js"></script> | |
| <script src="angular-ui-router/release/angular-ui-router.min.js"></script> | |
| <script src="index.js"></script> | |
| <script type="text/ng-template" id="home.component.html"> | |
| <a ui-sref="calendars.list">Ver calendars</a> | |
| </script> | |
| <script type="text/ng-template" id="calendarsList.component.html"> | |
| <a ui-sref="calendars.details({id:2})">Ver calendario ID: 2</a> | |
| <a ui-sref="calendars.details({id:10})">Ver calendario ID: 10</a> | |
| </script> | |
| <script type="text/ng-template" id="calendarsDetails.component.html"> | |
| <a ui-sref="home">Volver a home</a> | |
| <a ui-sref="calendars.list">Volver calendarios</a> | |
| <br>Calendar {{$ctrl.id}} | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app', ['ui.router', 'app.calendars']).config(($stateProvider, $urlRouterProvider) => { | |
| $stateProvider | |
| .state('home', { | |
| url: '', | |
| templateUrl: 'home.component.html' | |
| }); | |
| $urlRouterProvider.otherwise(''); | |
| }); | |
| angular.module('app.calendars', ['ui.router']).config($stateProvider => { | |
| $stateProvider | |
| .state('calendars', { | |
| abstract: true, | |
| url: '/calendars', | |
| template: '<ui-view/>' | |
| }) | |
| .state('calendars.list', { | |
| url: '', | |
| template: '<calendars-list></calendars-list>' | |
| }) | |
| .state('calendars.details', { | |
| url: '/:id', | |
| template: '<calendars-details id="$resolve.id"></calendars-details>', | |
| resolve: { | |
| id: $stateParams => $stateParams.id | |
| } | |
| }); | |
| }).component('calendarsList', { | |
| templateUrl: 'calendarsList.component.html', | |
| controller: [function () { | |
| }] | |
| }).component('calendarsDetails', { | |
| templateUrl: 'calendarsDetails.component.html', | |
| bindings: { | |
| id: '<' | |
| }, | |
| controller: [function () { | |
| }] | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment