我是angularJS的新手,我一直试图填写下拉列表框大约一周。我不能让它来填补拯救我的生命。我正确设置了吗?
angularJS代码
var CapitalRequestMultiMillInquiryController = function ($scope, $rootScope, $modal, $window, UsersService) {
$rootScope.title = 'Capital Request Multi Mill Inquiry';
$scope.mill = '';
$scope.jobNumber = '';
$scope.description = '';
$scope.amount = '';
$scope.amountOperator = '';
//below is a textbox entry may need to change
$scope.openonly = '';
$scope.users = '';
$scope.selectedProjectManager = '';
UsersService.getUsersWithId().then(function (objectTypes) {
$scope.getUsersWithId = _.filter(objectTypes, function (objectTypes)
{
return objectTypes.inactive == false;
});
});
$scope.search = function() {
//for each mill
CapitalRequestService.searchMulti("http://coucmmsweb.pca.com/CapitalRequest/Inquiry", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.selectedProjectManager, $scope.amount, $scope.amountOperator, $scope.openonly).then(function (results) {
$scope.counce = results;
});
CapitalRequestService.searchMulti("http://filcmmsweb.pca.com/CapitalRequest/Inquiry", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.selectedProjectManager, $scope.amount, $scope.amountOperator, $scope.openonly).then(function (results) {
$scope.filer = results;
});
CapitalRequestService.searchMulti("http://tomcmmsweb.pca.com/CapitalRequest/Inquiry", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.selectedProjectManager, $scope.amount, $scope.amountOperator, $scope.openonly).then(function (results) {
$scope.tomahawk= results;
});
CapitalRequestService.searchMulti("http://tridentval.pca.com/api/Inquiry/Inquiry/CapitalRequestMultiMillInquiry/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.selectedProjectManager, $scope.amount, $scope.amountOperator, $scope.openonly).then(function (results) {
$scope.valdosta = results;
});
CapitalRequestService.searchMulti("http://tridentder.pca.com/api/Inquiry/Inquiry/CapitalRequestMultiMillInquiry/Search", authenticatedUser.userName.toUpperCase(), $scope.mill, $scope.jobNumber, $scope.description, $scope.selectedProjectManager, $scope.amount, $scope.amountOperator, $scope.openonly).then(function (results) {
$scope.deridder = results;
});
}
};
这是我的服务......
app.service('UsersService', function ($http, cache) {
return {
getUsersWithId: function () {
var objectTypes = cache.get('usersWithId');
if (!objectTypes) {
return $http({ method: 'JSONP', url: "/api/core/users/userswithid?callback=JSON_CALLBACK", params: {} }).then(function (result) {
if (result.data.success) {
cache.put('usersWithId', result.data.data);
return result.data.data;
} else {
return [];
}
});
} else {
var deferred = $q.defer();
deferred.resolve(objectTypes);
return deferred.promise;
}
}
};
});
和我的控制器..
Public Class UsersController
Inherits System.Web.Mvc.Controller
'
' GET: /Users
<PCA.Core.Web.CompressionFilter> _
Function UsersWithId(callback As String) As ActionResult
Dim res As New PCA.Core.Web.JSON.Response
Dim catList As New List(Of ViewModels.Core.User)
For Each u In Trident.Core.Globals.TridentApp.ApplicationCache.Users.AllWithUserID
catList.Add(New ViewModels.Core.User(u))
Next
Try
res.success = True
res.message = ""
res.data = catList.OrderBy(Function(c) c.fullName)
Return New PCA.Core.Web.JSON.JSONPResult() With { _
.Data = res,
.Callback = callback
}
Catch ex As Exception
res.success = False
res.message = ex.Message
res.data = ""
Return New PCA.Core.Web.JSON.JSONPResult() With { _
.Data = res,
.Callback = callback
}
End Try
End Function
End Class
和我的观点
<div class="form-group">
<label>
Project Manager:
<select style="width: 180px" ng-options="user.value as user.userName for user in allUsers" ng-model="selectedProjectManager">
<option value=""></option>
</select>
</label>
</div>
UserController是一个不同于这个特定页面控制器的控制器我的老板告诉我,服务调用正确的控制器无关紧要我只需要设置我的角度函数并在视图中调用它应该工作他说...他们都去圣诞假期,我试图弄清楚这一点,任何帮助将不胜感激。