Permalink
Browse files

Add angular 1.5 component exemple

1 parent eea0ee4 commit 1b1e38474adc9821c5f1ce18f93213525146924b nilar committed Apr 12, 2016
Showing with 37 additions and 0 deletions.
  1. +37 −0 docs/css-modules-with-angular.md
@@ -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!**
- [ ] Controller vs Directive examples/rationale

0 comments on commit 1b1e384

Please sign in to comment.