Created
November 24, 2014 13:07
-
-
Save EmmanuelDemey/b8456da17b466b4ec48a to your computer and use it in GitHub Desktop.
Slide 124 - Using the scope property
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div data-ng-app="app"> | |
| <div class='html-content'><div data-ng-controller="ProductRatingCtrl"> | |
| <star-rating data-value="{{productMarkCss}}">2 comments</star-rating> | |
| Mark: | |
| <select data-ng-options="mark for mark in marks" data-ng-model="productMark" /> | |
| </div></div></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app',[]) | |
| .directive('starRating', function () { | |
| return { | |
| restrict: 'E', | |
| transclude: true, | |
| scope: { | |
| "value": "@" | |
| }, | |
| template: "<p data-ng-class=\"value\" data-ng-transclude></p>" | |
| }; | |
| }); | |
| var ProductRatingCtrl = function($scope) { | |
| $scope.marks = [ "one", "two", "three", "four", "five" ]; | |
| // Default CSS Class for the product. | |
| $scope.productMark = "three"; | |
| $scope.$watch('productMark', function() { | |
| $scope.productMarkCss = "rating " + $scope.productMark; | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment