【发布时间】: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"></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