我已经用 angularjs 构建了一个服务,但是我正在使用 jQuery DOM 选择器从隐藏的输入中查找 2 个值。这有一种味道,我想知道是否有非 jQuery 的方式来完成这个。添加 $scope,似乎是错误的。
app.factory('ignoredPropertiesService', ['$http', function ($http) {
var sessionId = $('input[name=SessionGuid]').val();
var contactId = $('input[name=ContactId]').val();
var ignoredPropertiesService = {};
ignoredPropertiesService.getIgnoredProperties = function () {
return $http.get("/Contact/IgnoredProperties?sessionGuid=" + sessionId + "&contactId=" + contactId);
};
ignoredPropertiesService.resfreshIgnoredProperties = function () {
return $http.get('/Contact/RefreshIgnoredProperties?sessionGuid=' + sessionId + '&contactId=' + contactId);
};
return ignoredPropertiesService;
}]);
我应该用 ng-model 装饰输入吗?
谢谢你,斯蒂芬