C'est la technique de base pour réaliser des SPA (application d'une seule page)
Pour cela , il faut récupérer l'extension angular-route sur le site d'angularJS.
Le code est simple:
This file contains 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
var myApplModule = angular.module('myAppli',['ngRoute']); | |
myApplModule.config(['$routeProvider', | |
function($routeProvider) { | |
$routeProvider. | |
when('/page1', { | |
templateUrl: 'partials/page1.tpl.html' | |
}). | |
when('/page2', { | |
templateUrl: 'partials/page2.tpl.html' | |
}). | |
otherwise({ | |
templateUrl: 'partials/pageD.tpl.html', | |
redirectTo: '/' | |
}); | |
}]); | |
myApplModule.controller('HelloController',['$scope', | |
function($scope) { | |
$scope.greeting = { text: 'Hello' }; | |
}]); |
Le serveur web est porté par Sinatra:
Quelques lectures:
Aucun commentaire:
Enregistrer un commentaire