Angularjs routage Vs Backbonejs routage

Angualrjs me frustre car il continue à générer des erreurs ou ne fonctionne tout simplement pas sur mon hôte local, bien que je suive exactement le tutoriel. Par exemple, ce tutoriel dont je veux tester le routage.

Et voici ce que je reçois

Erreur: [$ injector: modulerr] http://errors.angularjs.org/1.2.6/ $ injector / modulerr? P0 = app & p1 =% 5B% 24injecteur% 3Aunpr% 5D% 20http% 3A% 2F% 2F% 2Ferrors.angularjs. org% 2F1.2.6% 2F% 24injecteur% 2Funpr% 3Fp0% 3D% 2524routeProvider% 0As% 2F% 3C% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fjs% 2F3% 2F3% 2Flangue 3A6% 0AYb% 2Fm.% 24injecteur% 3C% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2F3% 2Fjs% 2Flocalhost% 2F2013% 2Fjs% 3A6% de% 3A6 % 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fangular.min.js% 3A30% 0Ad% 40http% 3A% 2F% 2Flocalhost% 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs % 2F% 3C% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fangular.min.js% 3A29% 0Aq% 40Français% 2F3% 2Fjs% 2Flocalhost% 2Flocal % 2F3% 2Fjs% 2Fangular.min.js% 3A7% 0Ae% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fjs% 2Fjs% 2Fjs% 3A7% 2Fjs% 3F7% 2% 3% 3% 7% du poids total % 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fangular.min.js% 3A32% 0AXb% 2Fc% 40Http% 3A% 2F% 2F% 2Flocalhost% 2Flocalhost% 2Ftest% 2F2013% 2 Fjs% 2Fangular% 2F3% 2Fjs% 2Fangular.min.js% 3A17% 0AXb% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2F3% 2F3% %Flocalhost% 2Fjs% 2Fjs% 2Fjs% 2Fjs% 2Fjs% 2Fjs% 2Fjs. 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fangular.min.js% 3A17% 0A% 40Http% 3A% 2F% 2Flocalhost% 2Flocalhost.min.js% 3A17% 0A% 2Fangs% 2Flangue Min.js% 3A200% 0Ax.Callbacks% 2Fc% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2F3% 2Fjs% 2Fjquery-1.10.1.min.js.% 3A4. 0% de%% de poids. fireWith% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fjquery-1.10.1.min.js% 3A4% 0A.ready% 40http% 3A% 2F% 2Flocalhost 2%. 2Fjs% 2Fangular% 2F3% 2Fjs% 2Fjquery-1.10.1.min.js% 3A4% 0Aq% 40http% 3A% 2F% 2Flocalhost% 2Ftest% 2F2013% 2Fjs% 2Fjs% 2F3% 2F3% 2Fjs% 2Fjs% 2Fjs% 3F4% js% 3A4% 0A

… c-1) + “=” + encodeURIComponent (“function” == typeof arguments [c]? arguments [c] .toSsortingn …

Voilà comment je pourrais le faire facilement dans Backbonejs!

var AppRouter = Backbone.Router.extend({ routes: { '': 'renderListContactsPage', 'list_contacts': 'renderListContactsPage', 'add_new_contact': 'renderAddNewContactPage', 'search_contacts': 'renderSearchContactsPage', 'edit_contact/:id': 'renderEditContactPage', '!article/edit/:url/': 'renderDynamicPage', ':parent/:url/': 'renderDynamicPage2', '!:module/:branch/:method/set:setnumber/page:pagenumber/': 'renderDynamicPage3', '!:module/:branch/:method?set=:setnumber&page=:pagenumber': 'renderDynamicPage3' }, renderAddNewContactPage: function () { var projectAddView = new ProjectAddView(); projectAddView.addContactPage(); }, renderListContactsPage: function () { var projectListView = new ProjectListView(); projectListView.listContactsPage(); }, renderSearchContactsPage: function () { var projectSearchView = new ProjectSearchView(); projectSearchView.searchContactPage(); } ... 

Qu’est-ce que j’ai manqué dans Angular? J’utilise la dernière version – v1.2.6 et ils ont une documentation si médiocre!

MODIFIER:

html,

    AngularJS        

angular,

 var app = angular.module("app", []); app.config(function($routeProvider){ $routeProvider.when("/", { templateUrl: "app.html", controller: "AppCtrl" } ); }); app.controller("AppCtrl", function($scope){ $scope.model = { message: "This is my app!!!" } }); 

Vous avez besoin que ngRoute soit injecté en tant que dépendance dans votre déclaration de module.

 var app = angular.module("app", []); 

devrait être

 var app = angular.module("app", ['ngRoute']); 
 var app = angular.module("app", ['ngRoute']); app.config(['$routeProvider', function($routeProvider){ $routeProvider.when("/", { templateUrl: "app.html", controller: "AppCtrl" } ); }]);