Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <div id="notificationsTile">
  2. <div class="blue">
  3. <div class="step">
  4. <ul ng-repeat="item in Model.DisplayNotifications">
  5. <li itemPriority = {{item.Priority}}>
  6. <h3>{{ item.EndDate | date: 'dd MMMM' }}</h3>
  7. <p>{{ item.NotificationName }}</p>
  8. </li>
  9. </ul>
  10. </div>
  11. </div>
  12. </div>
  13.  
  14. scope.$watch("itemPriority", function(newVal, oldVal){
  15. debugger;
  16. });
  17.  
  18. notificationsTileModule.directive('spNotificationsTile', function (spNotificationsService, spSessionStorageService) {
  19. return {
  20. restrict: 'E',
  21. replace: true,
  22. scope: {
  23. priority: '=itemPriority'
  24. },
  25. templateUrl: '/_catalogs/masterpage/SPDP.Portal/Views/NotificationTile/NotificationTile.html',
  26. link: function (scope, element, attrs) {
  27.  
  28. var model = scope.Model = {
  29. DisplayNotifications: []
  30.  
  31. };
  32.  
  33. //model.Priority = scope.itemPriority;
  34.  
  35. scope.$watch('priority', function(newVal, oldVal){
  36. debugger;
  37. });
  38. }
  39. });
  40.  
  41. <ul ng-repeat="item in Model.DisplayNotifications">
  42. <li item-priority="item.priority">{{item.priority}}
  43. </li>
  44. </ul>
  45.  
  46. app.directive('itemPriority', function() {
  47. return {
  48. restrict: 'A',
  49. scope: {
  50. priority: '=itemPriority'
  51. },
  52. link: function(scope, element, attr) {
  53. scope.$watch('priority', function() {
  54. console.log(scope.priority);
  55. });
  56. }
  57. }
  58. });
  59.  
  60. <ul ng-repeat="item in Model.DisplayNotifications">
  61. <li>
  62. <div ng-class="{'alert-danger': item.priority < 2,
  63. 'alert-warning': item.priority >= 2 && item.priority < 4,
  64. 'alert-info': item.priority >= 4}">
  65. {{item.priority}}
  66. </div>
  67. </li>
  68. </ul>
  69.  
  70. <div sp-notifications-tile items="Model.DisplayNotifications" class="alert">
  71. <ul>
  72. <li ng-repeat="item in Model.DisplayNotifications">
  73. ...
  74.  
  75. app.directive('spNotificationsTile', function() {
  76. return {
  77. restrict: 'A',
  78. scope: {
  79. items: '='
  80. },
  81. link: function(scope, element, attr) {
  82. scope.$watch('items', function() {
  83. var firstItem = element.find('li')[0];
  84. var firstPriority = angular.element(firstItem).scope().item.priority;
  85.  
  86. if (firstPriority > 3)
  87. element.addClass('alert-warning');
  88. else
  89. element.removeClass('alert-warning');
  90. }, true);
  91. }
  92. }
  93. })
  94.  
  95. $scope.itemPriority = item.Priority ;
  96.  
  97.  
  98. scope.$watch('itemPriority ', function( status )
  99. {
  100. console.log(status);
  101. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement