ng-repeat在UIKIT下拉列表中不起作用

时间:2017-03-23 08:55:21

标签: javascript angularjs uikit

我有uikit下拉模板,其中我正在尝试添加ng-reapet但是下拉不工作。

伙计们请帮忙.....

 <div class="uk-button-dropdown" uk-dropdown="{mode:'click'}">
     <button class="md-btn">Click me <i class="material-icons">&#xE313;</i></button>
         <div class="uk-dropdown">
             <ul class="uk-nav uk-nav-dropdown">

                 <li ng-repeat="item in locationName">
                     <a href="">{{item}}</a>
                 </li>
            </ul>
         </div>
    </div>

模块

var addlocationModule = angular.module('addLocationApp', ['ngDialog']);    
addlocationModule.controller('addLocationController', function ($scope, $http, $window, ngDialog) {


    $scope.initialize = function(alllocation,loggedInEmployee) 
    {
            $scope.alllocations = alllocation;
            $scope.loggedInEmployee = loggedInEmployee;

            $scope.locationName = [];
            $scope.alllocations.forEach(function(resource) {
            $scope.locationName.push(resource.title);
            });


    }

    $scope.addLocations = function() {
          $http.post('/addLocationName',$scope.location).then(function successCallback(response) {
            if(response.data.status){
              $scope.alllocations.push(response.data.location);
              $scope.location.name="";
              $scope.location.description="";
              }
          }, function errorCallback(response) {
            // called asynchronously if an error occurs
            // or server returns response with an error status.
          })
    }
    });

1 个答案:

答案 0 :(得分:0)

你应该在ul标签中添加ng-repeat

<ul class="uk-nav uk-nav-dropdown" ng-repeat="item in locationName">
    <li>
        <a href="">{{item}}</a>
    </li>
</ul>

我认为它会帮助你。