无法将数据提取到ng-template中

时间:2014-08-11 09:50:50

标签: angularjs angularjs-directive angularjs-scope angularjs-ng-repeat

我正在使用带有angular.js的codeigniter。我已经创建了ng-template,我可以从$ http方法获取数据但是无法获取ng-template。我没有得到错误的地方。这是我的代码。

//Angular.js
var app1 = angular.module("HomeApp",['uiSlider','ui.bootstrap']);
app1.config(function ($routeProvider) {
  $routeProvider
    .when('/hallinfo', {
      templateUrl: 'hallinfo.html',
      controller: 'HomeCtrl'
    })
    .when('/hallfeature',{
      templateUrl:'hallfeature.html',
      controller:'HomeCtrl'
    })
    .otherwise({
      redirectTo: "/hallinfo"
    });
});

app1.controller('HomeCtrl', function( $scope,$http,$q,$location,$window,$routeParams,$modal, $log) {
$scope.get_hallfeature=function(id){
     return $http({
        url:  'home/get_hallfeatures/'+id,
        method: "POST"
      }).success(function(addData) {
        $scope.hallfeature={};
        $scope.hallfeature=addData; 
        console.log($scope.hallfeature);
        });
    }
}

//在上面的代码中我在$ scope.hallfeature中获取数据(我在控制台中看到过)但在ng-template中没有

// hallfeature模板

<script type="text/ng-template" id="hallinfo.html">
//from here i am passing parameter(hall_id) to get hall features of particular hall
<div ng-repeat = "hall in hallinfo">
//i have my data here 
<button ng-click="get_hallfeature(hall.hall_info_id)"></button>
//on click it goes to my app.js get_hallfeature function
</div>
</script>

//hallfeature template
    <script type="text/ng-template" id="hallfeature.html">
    <div ng-repeat = "feature in hallfeature" >
    <table border="border:3px dashed blue" class="table" cellpadding="5" cellspacing="0"  >
                        <tbody>
                            <tr>
                                <th> Dining Capacity : </th>
                                <td >{{feature.dining_capacity}}</td>
                            </tr>
                            <tr>
                              <th>Kitchben Type :</th>
                              <td>{{feature.kitchen_type}}</td>
                            </tr>
                            <tr>
                              <th>Receiption Capacity :</th>
                              <td>{{feature.receiption_capacity}}</td>
                            </tr>
                            <tr>
                              <th>Rooms :</th>
                              <td>{{feature.number_of_rooms}}</td>
                            <tr/>
                            <tr>
                              <th>Total Area :</th>
                              <td>{{feature.total_area}}</td>
                              </tr>
                            <tr>
                              <th>Conference Facility:</th>
                              <td>{{feature.conference_facility}}</td>
                            </tr>
                        </tbody>
                      </table>
                      </div>
    </script>

//我的hallinfo模板工作正常。告诉我我在哪里弄错了。 我点击了hallinfo ng-template点击了get_hallfeature。

0 个答案:

没有答案