【问题标题】:ng-repeat not working in UIKIT dropdownng-repeat 在 UIKIT 下拉菜单中不起作用
【发布时间】:2017-03-23 08:55:21
【问题描述】:

我有 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.
          })
    }
    });

【问题讨论】:

  • .then内调用$scope.initialize函数
  • 谢谢,但它已经被调用并且我已经有数据了。这里我只展示了 .html 文件的一部分
  • 不要从 html 调用它。在$scope.location.description="" 行之后的`$scope.addLocations` 函数中调用它
  • 当然让我试试..
  • 哎呀这也行不通!!! :(

标签: javascript angularjs uikit


【解决方案1】:

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

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

我想它会帮助你。

【讨论】:

  • 谢谢你,但它仍然无法正常工作.... UIKIt 导致一些问题无法解决!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多