我正在检查我的控制器中的值.这是我的代码.
var contents = atob(response.documents);
// I checked the value in contents . it is displaying ""
if(contents === ""){
// no contents
}
Run Code Online (Sandbox Code Playgroud)
if条件重新调整为false,内容为""且内容有数据时.如何查看条件?
我收到此错误并且我的验证工作不正常我使用CDN,因为我的数据存储在localstorage中
Uncaught TypeError: Cannot read property '$$minErr' of undefined
(anonymous function) @ angular-resource.js:8
(anonymous function) @ angular-resource.js:6
Run Code Online (Sandbox Code Playgroud)
我用这个CDN
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
并听到我的Html表格
<div> <input id="email"
class="form-control"
type="email"
name="email"
ng-model="user.email"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"
placeholder="Enter Your Email"
required
/>
<span ng-show="myForm.email.$dirty && myForm.email.$invalid" class="color">Invalid Email address.</span>
<span ng-show="myForm.email.$dirty && form.email.$error.required">
Email is required
</span>
</div>
<div> <input type="password"
class="form-control"
ng-minlength="5"
ng-maxlength="10"
ng-model="loginCtrl.user.pass"
name="pass"
id="pass"
placeholder="Enter Your Password"
required
/>
<span ng-show="myForm.pass.$dirty && myForm.pass.$error.required" class="color">Required!!!</span> <br>
</div>
<div align="center">
<input ng-click="myFun()"type="submit" class="btn btn-success" ng-disabled="myForm.$invalid" value="Login" > …Run Code Online (Sandbox Code Playgroud) 我想将一些数据传递给$ mdDialog.事实上,我有牵引控制器在单独的文件中.这是我的控制器代码
function openDialog(id) {
$mdDialog.show({
locals:{
profileId: id
},
controller: ['$scope', 'profileId', function($scope, profileId) {
var self = this;
self.profileId= profileId;
}],
controllerAs: 'profileCtrl',
templateUrl: 'view/profile.html',
parent: angular.element(document.body),
clickOutsideToClose:true
})
}
Run Code Online (Sandbox Code Playgroud)
我希望tp将profileId传递给profileController并显示配置文件数据.在配置文件控制器中,我得到数据
function profileController($scope,..., profileId){
}
Run Code Online (Sandbox Code Playgroud)
但这个错误在控制台中出现了
Error: [$injector:unpr] Unknown provider: profileIdProvider <- profileId<- ProfileController
Run Code Online (Sandbox Code Playgroud)
这个错误是什么以及如何解决?
我有2 List<String>s,第一个代表所有项目的列表,第二个代表选定的项目。
因此,我Map<String, Boolean>将从这些列表中获得一个,其键都是list1的所有项,值是list2.contains(itemOfList1)(true或false)。
Map<String, Boolean> mapOfDataListTest = itemList.stream()
.collect(Collectors.toMap(key -> key, value -> true));
Run Code Online (Sandbox Code Playgroud) 我想创建一个动态的指令.在此指令中,定义具有input元素的模板.实际上,这个元素ng-model必须是动态的,并且$scope.name在控制器中使用.
app.directive('helloWorld', function() {
return {
restrict: 'E',
replace: true,
scope: {
name: '@',
path:'@',
},
template: '<input\
type="text"\
name="{{name}}"\
ng-model="{{name}}"\
/>\,
link: function(scope, elem, attrs) {
},
controller:{
$scope.$watch($scope.name, function (newValue, oldValue) {
}
}
});
Run Code Online (Sandbox Code Playgroud) 我想在angularjs中创建嵌套的json对象。我的对象是这样的:
{
"marketerId": 1,
"baskets": [
{
"customer": {
"phone": ""
},
"region": 1,
"orders": [
{
"bookId": 1,
"count": 5
},
{
"bookId": 2,
"count": 52
}
]
},
{
"customer": {
"phone": ""
},
"region": 1,
"orders": [
{
"bookId": 1,
"count": 12
},
{
"bookId": 2,
"count": 2
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
为了动态创建该对象,我编写此代码。假设订单和商品已经初始化,则创建表格。例如,项目和订单的大小2.是否有更好的方法来构建嵌套的json对象?
<input ng-model="formData.marketerId" />
<div class="row" ng-repeat="item in items track by $index">
<input ng-model="formData.baskets[$index].customer.phone" />
<input ng-model="formData.baskets[$index].region" />
<div ng-repeat="order in orders track by …Run Code Online (Sandbox Code Playgroud) 此HTML邀请按钮单击:
<p><button class="btn btn-info" ng-click="ResetEventStation()">
Choose a different station</button></p>
Run Code Online (Sandbox Code Playgroud)
哪个调用此函数:
$scope.ResetEventStation = function()
{
localStorage.removeItem("stationId");
localStorage.removeItem("stationName");
localStorage.removeItem("isRegistrationStation");
$scope.stationId = -1;
$scope.stationName = '';
$scope.isRegistrationStation = false;
}
Run Code Online (Sandbox Code Playgroud)
我可以断点并单步执行该函数,但是当我跨过右括号时,我得到
angular.js:13236错误:[orderBy:notarray]预期的数组,但收到了:{“ customer_id”:97,“ event_id”:6,“ station_id”:7,“ station_name”:“圣潘克拉斯”,“ customer_name”: “ mawg”,“ event_title”:“事件一”,“令牌”:“ 20000097-6ee02241-7231-4f8d-9956-5cf5022de147”} http://errors.angularjs.org/1.5.0/orderBy/notarray?p0 =%7B%22customer_id%22%…%22%2C%22token%22%3A%2220000097-6ee02241-7231-4f8d-9956-5cf5022de147%22%7D at angular.js:68 at angular.js:20410 at fn(在编译时评估(angular.js: 14086)、: 4:200)(位于Scope。$ digest(angular.js:16655)(位于ChildScope)的regularInterceptedExpression(angular.js:15213).HTMLButtonElement的$ apply(angular.js:16928))。(htmlularElement.dispatch)(angular.js:24551)(jquery-2.1.1.min.js:3)(HTMLQueryElement.r.handle(jquery-2.1.1.min.js:3)
谷歌搜索显示它是一个过滤器错误,而且,可以肯定的是,浏览器控制台显示了此功能,我假设Angular为我生成了该功能:
(function($filter,ensureSafeMemberName,ensureSafeObject,ensureSafeFunction,getStringValue,ensureSafeAssignContext,ifDefined,plus,text
/*``*/) {
"use strict";
var fn=function(s,l,a,i){var v0,v1,v2,v3=l&&('ResetEventStation' in l);v2=v3?l:s;if(!(v3)){if(s){v1=s.ResetEventStation;}}else{v1=l.ResetEventStation;}ensureSafeObject(v1,text);if(v1!=null){ensureSafeFunction(v1,text);v0=ensureSafeObject(v2.ResetEventStation(),text);}else{v0=undefined;}return v0;};return fn;
})
Run Code Online (Sandbox Code Playgroud)
我不太了解发生了什么。有人可以告诉我我做错了什么,以及如何纠正错误?
我可以看到它{"customer_id":97,"event_id":6,"station_id":7,"station_name":"St. Pancras","customer_name":"mawg","event_title":"Event one","token":"20000097-6ee02241-7231-4f8d-9956-5cf5022de147"}不是数组,但是不确定为什么要引用它。
我想要同一类的两个BigDecimal类型属性的总和,并将它们与该类的某些其他属性分组。
我尝试使用Collectors.groupingBy()和Collectors.reducing()方法,但这仅适用于可以汇总的一个属性。
Employee类具有以下属性:
class Employee{
private String name;
private BigDecimal salary;
private BigDecimal bonus;
private String department;
// Getters and Setters
}
employeeList.stream().collect(Collectors.groupingBy(
Employee::getDepartment, Collectors.reducing(
BigDecimal.ZERO,
(id, emp) -> id.add(emp.getSalary().add(emp.getBonus)),
BigDecimal::add)));
Run Code Online (Sandbox Code Playgroud)
根据代码的最后一部分,Collectors.reducing(),我希望将薪金和奖金的总和与各个部门一起分组。例如,
部门A-
员工1-工资1000,奖金100
员工2-薪金2000,奖金100
部门B-
员工3-薪金5000,奖金100
现在我想要一张像下面的地图:
[部门A,3200],[部门B,5100]
我有以下课程:
public List<Racer> createListOfRacers() throws IOException {
Stream<String> abbreviationsOfRacers = fileLoader.createStreamFromFile("src/main/resources/abbreviations.txt");
Stream<Racer> racerList = abbreviationsOfRacers
.map(this::createRacer);
return racerList.collect(toList());
}
Run Code Online (Sandbox Code Playgroud)
在这一行抛出异常:
.map(this::createRacer);
Run Code Online (Sandbox Code Playgroud)
创建包含在同一类中的 Racer 的方法:
private Racer createRacer(String line) {
return new Racer(extractAbbreviationOfTheRacer(line), extractNameOfTheRacer(line), extractTeamOfTheRacer(line));
}
private String extractNameOfTheRacer(String line) {
return line.substring(line.indexOf('_') + 1, line.lastIndexOf('_'));
}
private String extractTeamOfTheRacer(String line) {
return line.substring(line.lastIndexOf('_') + 1);
}
private String extractAbbreviationOfTheRacer(String line) {
return line.substring(0, line.indexOf('_'));
}
Run Code Online (Sandbox Code Playgroud)
赛车类:
public class Racer {
private String abbrevition;
private String name;
private String team;
private …Run Code Online (Sandbox Code Playgroud) reader = new BufferedReader(new InputStreamReader(inputStream))reader = new InputStreamReader(new BufferedInputStream(inputStream))哪个更好?为什么?
angularjs ×5
java ×4
javascript ×4
java-8 ×3
java-stream ×3
buffered ×1
css ×1
html5 ×1
inputstream ×1
json ×1
list ×1
reader ×1