Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="notificationsTile">
- <div class="blue">
- <div class="step">
- <ul ng-repeat="item in Model.DisplayNotifications">
- <li itemPriority = {{item.Priority}}>
- <h3>{{ item.EndDate | date: 'dd MMMM' }}</h3>
- <p>{{ item.NotificationName }}</p>
- </li>
- </ul>
- </div>
- </div>
- </div>
- scope.$watch("itemPriority", function(newVal, oldVal){
- debugger;
- });
- notificationsTileModule.directive('spNotificationsTile', function (spNotificationsService, spSessionStorageService) {
- return {
- restrict: 'E',
- replace: true,
- scope: {
- priority: '=itemPriority'
- },
- templateUrl: '/_catalogs/masterpage/SPDP.Portal/Views/NotificationTile/NotificationTile.html',
- link: function (scope, element, attrs) {
- var model = scope.Model = {
- DisplayNotifications: []
- };
- //model.Priority = scope.itemPriority;
- scope.$watch('priority', function(newVal, oldVal){
- debugger;
- });
- }
- });
- <ul ng-repeat="item in Model.DisplayNotifications">
- <li item-priority="item.priority">{{item.priority}}
- </li>
- </ul>
- app.directive('itemPriority', function() {
- return {
- restrict: 'A',
- scope: {
- priority: '=itemPriority'
- },
- link: function(scope, element, attr) {
- scope.$watch('priority', function() {
- console.log(scope.priority);
- });
- }
- }
- });
- <ul ng-repeat="item in Model.DisplayNotifications">
- <li>
- <div ng-class="{'alert-danger': item.priority < 2,
- 'alert-warning': item.priority >= 2 && item.priority < 4,
- 'alert-info': item.priority >= 4}">
- {{item.priority}}
- </div>
- </li>
- </ul>
- <div sp-notifications-tile items="Model.DisplayNotifications" class="alert">
- <ul>
- <li ng-repeat="item in Model.DisplayNotifications">
- ...
- app.directive('spNotificationsTile', function() {
- return {
- restrict: 'A',
- scope: {
- items: '='
- },
- link: function(scope, element, attr) {
- scope.$watch('items', function() {
- var firstItem = element.find('li')[0];
- var firstPriority = angular.element(firstItem).scope().item.priority;
- if (firstPriority > 3)
- element.addClass('alert-warning');
- else
- element.removeClass('alert-warning');
- }, true);
- }
- }
- })
- $scope.itemPriority = item.Priority ;
- scope.$watch('itemPriority ', function( status )
- {
- console.log(status);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement