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.
- Host: GitHub
- URL: https://github.com/normandy72/routing-with-controller
- Owner: Normandy72
- Created: 2023-01-20T10:40:47.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T11:09:35.000Z (over 3 years ago)
- Last Synced: 2025-01-14T12:46:32.263Z (over 1 year ago)
- Topics: angular, angularjs, css, css3, html, html5, javscript, js
- Language: JavaScript
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.
***