An open API service indexing awesome lists of open source software.

https://github.com/normandy72/routing-with-controller

Routing State with Controller in AngularJS. Coursera course "Single Page Web Applications with AngularJS" by Yaakov Chaikin.
https://github.com/normandy72/routing-with-controller

angular angularjs css css3 html html5 javscript js

Last synced: about 2 months ago
JSON representation

Routing State with Controller in AngularJS. Coursera course "Single Page Web Applications with AngularJS" by Yaakov Chaikin.

Awesome Lists containing this project

README

          

# Routing State with Controller
#### Given the Following State Config
```
.state('home', {
url: '/',
templateUrl: 'home.html'
});
```
__home.html__
```


content

content


```
`
` - inefficient because this tag is only here to declare controller

#### Declare Controller In State Configuration
```
.state('home', {
url: '/',
templateUrl: 'home.html',
controller: 'HomeCtrl as home'
});
```
__home.html__
```

content

content

```
***
#### _Summary_
* We can declare a controller that is responsible for the state's template right in the state's declaration.
* Use
* `controller: 'CtrlName as label'` or
* `controller: ctrlName, controllerAs: 'label'`;
* In the template, use label.data as usual with controllerAs syntax.
***