2014-05-17 2 views
1

각도를 사용하여 내 ionic.js 웹 앱에서 지시문을로드하는 데 문제가 있습니다. 내가 그러나 지시어 즉 <div class="blaha" ng-transclude>abc123</div> ... 난 아래 치명적인 뭔가를 놓치고 있습니까 템플릿에 전달되지 않습니다로드되지 않습니다, 템플릿에 컨트롤러에서 변수 {{someTitle}}을 전달할 수 있습니다ionic.js에서 각도 지시어가 작동하지 않습니다.

이온 템플릿 :

<ion-view title="Roll the Dice"> 
    <ion-content has-tabs="true"> 
     <div my-dice>{{someTitle}}</div> 

     <div class="card"> 
      <div class="item item-text-wrap"> 
       {{someTitle}} 
      </div> 
     </div> 


     <button class="button button-dark button-full button-positive"> 
      Full Width Block Button 
     </button> 

    </ion-content> 
</ion-view> 

컨트롤러 코드 :

'use strict'; 
angular.module('TrueDice.controllers', []) 


// A simple controller that fetches a list of data from a service 
.controller('HistoryIndexCtrl', function($scope, TrueRandomService) { 

     if($scope.rands="undefined"){ 
      $scope.rands = []; 
     } 
     TrueRandomService.getRand(1).success(function(data){ 
      $scope.rands.unshift(data); 
      console.log(data); 
     }); 
}) 
.controller('HistoryDetailCtrl', function($scope, $stateParams, TrueRandomService) { 
    //currently empty 

}).controller('RollViewCtrl', function($scope){ 
    $scope.someTitle="BLA"; 

}).directive('my-dice', ['$rootScope', function($rootScope) { 
     return { 
      restrict: 'E', 
      template: '<div class="blaha" ng-transclude>abc123</div>', 
      replace: true, 
      transclude: true, 
      scope: {}, 
      controller: function($scope, $element) { 
       //currently empty 
      } 
     } 
    }]); 

NotWorking

답변

6

R 지시어 이름에서 가져 가십시오 - :

directive('myDice', ['$rootScope', function($rootScope) { 

restrict: 'E'에 따라, 당신은 HTML의 요소를 배치해야합니다 :

<my-dice>{{someTitle}}</my-dice> 

example

관련 문제