Permalink
Browse files

Merge pull request #135 from nlarche/master

Add angular 1.5 component exemple
  • Loading branch information...
2 parents f989e70 + 1b1e384 commit 90224db9b575816ea7b676347c2b18e33163316f @markdalgleish markdalgleish committed on GitHub Nov 6, 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 90224db

Please sign in to comment.