Routing in angularjs

Главная » Tutorials » JavaScript » Routing in angularjs

In this lesson we will finish to learn angular basics. Today we will consider routing.

Routing in angular lets your to create “effect multi-page app” in single page web app.
For providing routing in your app you need to include angular-route module.. Don’t forget add it to dependency while app init. Also in view you need to add element with ng-view directive. Views will be rendered inside this directive bases on some conditions.
What are the conditions? I talk about routes, which will be available in your app after routes settings. For this purpose angular provides $routeProvider object, which has different properties and methods.
We will consider two important methods:
.when(url, object) – first parameter is url, second parameter is route object. In our tuts we add two properties: view template and controller (this parameter is not required).
.otherwise(url) – it shows default view (if routeProvider hasn’t route among the described).
In players list view I added link with format


I notice, view is single html code fragments.

Подписаться на рассылку

Будьте в курсе - получайте последние статьи на свой email

Ваша подписка успешно оформлена

Pin It on Pinterest

Share This