2017-02-08 2 views
1

ich eine Richtlinie für die Förderung mache, und ich bin eine seltsame problem-
Im folgenden Code immer eine Variable scope.promoDetailUrl, Als ich und unter $ rootScope genannt ist .configData ['PROMOTIONS'] Daten in scope.promoDetailUrl Variable dann funktioniert das in Richtlinie Vorlage.

Aber wenn ich configData ['PROMOTIONS'] in Vorlage verwenden, dann funktioniert das nicht.

Sehen Sie bitte meine Code-

(function(){ 

'use strict'; 

angular.module('promotions', []) 
    .directive('promotion', ['$interval', '$rootScope','HttpServiceCall', promotion]) 


function promotion($interval, $rootScope, HttpServiceCall){ 
    return{ 
     restrict:'EA', 
     templateUrl: 'partials/directive-templates/promotion-template.html', 
     replace:true, 
     scope:{ 
      list:'=' 
     }, 
     compile: function(){ 
      return{ 
       post: function postLink(scope, iElement, iAttrs) { 
        console.log("listDirective",scope.list,$rootScope) 
        var startData = moment(scope.list.StartDate); 
        var endDate = moment(scope.list.EndDate); 
        scope.diff = {}; 
        scope.list.image = environments[env].RESOURCE_URL_AMAZON + environments[env].AMAZON_PROMOTION_FOLDER_PATH + scope.list.image; 
        scope.promoDetailUrl = $rootScope.configData['PROMOTIONS']; 
       } 
      } 
     } 
    } 
} 

}())

<div class="col-xs-12 col-sm-4 promotion-pro" ng-show="isHMSisZero === 'false'"> 
<div class="pro-other-option-box"> 
    <figure ng-attr-title="{{list.altTag}}"><img ng-src="{{list.image}}"></figure> 
    <div> 
     <h3>{{list.title}}</h3> 
     <p>{{list.shortDescription}}</p> 
     <div class="timer-section clearfix"> 
     <!-- <p><a href="{{list.moreInfo}}">{{'link_more_info' | translate}}</a></p> --> 
      <!-- not working --> 
     <p><a href="#/{{configData['PROMOTIONS']}}/{{list.promoID}}">{{'link_more_info' | translate}}</a></p> 
     <div class="pro-option-timer"> 
     <div class="timer-current"> 
      <strong>{{'promo_list_offer_text' | translate}}</strong> 
      <span class="time-detail"><span ng-show="diff.days>0">{{diff.days}} {{'promo_list_days' | translate}} </span> <span ng-show="isHMSisZero === 'false'">{{diff.hours}} : {{diff.minutes}} : {{diff.seconds}}</span></span> 
     </div> 
     </div> 
    </div> 
    </div> 
</div> 

Antwort

1

Sie sollten $root nutzen können, um die $rootScope in der Ansicht zu verweisen wie folgt:

<p><a href="#/{{ $root.configData['PROMOTIONS'] }}/{{list.promoID}}">{{'link_more_info' | translate}}</a></p> 
Verwandte Themen