Skip to content

Commit

Permalink
Merge pull request #135 from nlarche/master
Browse files Browse the repository at this point in the history
Add angular 1.5 component exemple
  • Loading branch information
markdalgleish committed Nov 6, 2016
2 parents f989e70 + 1b1e384 commit 90224db
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/css-modules-with-angular.md
Expand Up @@ -29,6 +29,43 @@ angular.module('myApp').controller('MyController', ($scope) => {


--- ---


## CSS Modules with angular 1.5 component

[Demo](http://nlarche.github.io/css-modules-angular-1/)

```css
.content { /* ... */ }
.bacon { /* ... */ }
.pancakes { /* ... */ }
```

```js
import angular from 'angular'
import styles from './index.css'

var template = `
<div class="{{::$ctrl.styles.content}}">
<div class="{{$ctrl.styles.pancakes}}">pancakes</div>
<div ng-class="$ctrl.styles.bacon">bacon</div>
</div>`;

angular
.module('app', [])
.component('myComponent', {
template: template,
controller: Controller
});


function Controller() {
var vm = this;

vm.$onInit = function() {
vm.styles = styles;
}
}
```

**This needs expansion/revision by someone who really knows angular. Maybe that's you!** **This needs expansion/revision by someone who really knows angular. Maybe that's you!**


- [ ] Controller vs Directive examples/rationale - [ ] Controller vs Directive examples/rationale
Expand Down

0 comments on commit 90224db

Please sign in to comment.