我正在使用Angular 2,一切都在Chrome中运行良好,但我开始在Firefox中收到以下错误:
EXCEPTION:0 - { - isTrusted":true}在core.umd.js中
我不知道是什么导致它或它来自哪里,所以我甚至不知道从哪里开始调试它.我做了一些谷歌搜索,但找不到任何有用的东西.这是我在控制台中看到的图像:
有谁知道这意味着什么?
我应该创建一个数组并将数字从最小到最大排序.这是我到目前为止:
public class bubbleSort {
public static void sort (int [] arrayName){
int temp;
for (int i = 0; i < arrayName.length-1; i++)
{
if(arrayName[i] > arrayName[i+1])
{
temp=arrayName[i];
arrayName[i]=arrayName[i+1];
arrayName[i+1]=temp;
i=-1;
}
}
}
public static void main(String[] args) {
int [] arrayName = new int[10];
for (int i = 0; i < arrayName.length; i++) {
arrayName[i] = (int)(Math.random()*100);
}
System.out.println(sort(arrayName));
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将其打印出来的最后一行收到错误.我究竟做错了什么?
我有一些代码使div的背景颜色渐渐消失.代码目前按照我想要的方式工作,但我想用变量替换它的一部分,以便我可以更改它将影响的div.它所影响的div的id为"one",但当我尝试将变量的值设为变量并将变量放在放置的代码中时,它就不再起作用了.有没有不同的方法可以让它发挥作用?这是代码:
var temp2 = "one";
$(document).ready(function () {
$("#temp2").click(function () {
$("#temp2").animate({
"opacity": "0.15"
}, "slow");
});
});
Run Code Online (Sandbox Code Playgroud) 我使用 JQuery 来处理对 .NET 控制器的 http 请求(我使用的是 .NET MVC 4.5.2),但现在我开始使用 Angular 2,所以我想用 Angular 2 处理那些 JQuery AJAX 调用。这是我之前使用的 JQuery,它的工作方式和我想要的一样:
$.get('/Plan/Variety/ListVarietiesInMenuForSelling')
.done(function(data){
console.log(data)
});
Run Code Online (Sandbox Code Playgroud)
我如何设置我的 Angular 2 服务来完成同样的事情?我试过下面的代码:
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
@Injectable()
export class SellingMenuVarietiesService {
private url = '/Plan/Variety/ListVarietiesInMenuForSelling'; // URL to web api
constructor(private http: Http) { }
getVarieties() {
return this.http.get(this.url);
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用。相反,我在控制台中收到此错误:
EXCEPTION: Uncaught (in promise): TypeError: Cannot read property '0' of undefined core.umd.js:3462
Run Code Online (Sandbox Code Playgroud)
我能够找到处理 …
我有一个由 for 循环生成的品种列表。该列表中的每个项目旁边都有一个按钮,以便可以删除特定的列表项目。每个按钮都会打开一个模式,您可以在其中确认是否要删除该品种。我不希望页面上有无限数量的模态,所以我将模态放在 for 循环之外,并希望将 id 从初始删除按钮传递给模态,以便模态知道要删除的种类。我想为了做到这一点,我需要创建一个变量。我通过放入#varietyToDelete="{{variety.PerProjectVarietyId}}"初始删除按钮来尝试此操作,然后在模式中的最终删除按钮内,我添加了以下内容:(click)="removeVariety(#varietyToDelete)"
为了更好地查看我的代码,这是我拥有的 for 循环的相关部分:
<div *ngFor="let variety of varieties; let i=index">
...
<div class="varietyName">
<a href="#deleteVarietySelling" #varietyToDelete="{{variety.PerProjectVarietyId}}" data-toggle="modal">
<i class="fa fa-minus"></i>
</a>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的模态,我想将该变量传递给:
<div class="modal fade alert" id="deleteVarietySelling" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<a href="#" class="close-modal" data-dismiss="modal">×</a>
<p class="confirmation-message">
Are you sure you want to delete this variety?
</p>
<div class="row">
<div class="removeCancel">
<a href="#" class="cancel-button" data-dismiss="modal">Cancel</a>
<a href="#" class="remove-button" (click)="removeVariety(#varietyToDelete)">Remove</a>
</div>
</div>
</div>
</div>
</div> …Run Code Online (Sandbox Code Playgroud) 我有一个要显示为货币的输入。我只允许小数点后两位,并且只允许数字,并在必要时自动添加逗号。基本上,如果用户键入“ 12345”,我希望输入自动显示为“ 12,345.00”。“ 12,345”也是可以接受的,但是如果他们输入“ 12345.5”,则需要显示为“ 12,345.50”。我试图使用管道来完成此操作,并决定使用“数字”管道,因为我不想显示货币符号(输入之前我已经有一个美元符号作为标签)。
这是我的代码:
<input [ngModel]="Amount | number: '1.2-2'" (ngModelChange)="updateAmount($event)" class="form-control" id="Amount" name="Amount" tabindex="4" type="number" autocomplete="off">
Run Code Online (Sandbox Code Playgroud)
我有一些问题。
管道'DecimalPipe'的无效参数'11 .00a'
发生此错误后,过滤器将完全停止工作。
如果将输入设置为,type="number"并输入1234,则值将为1,234,但是输入将消失,并且我将在控制台中收到以下消息:
指定的值“ 1,234”不是有效数字。该值必须与以下正则表达式匹配:-?(\ d + | \ d +。\ d + |。\ d +)([eE] [-+]?\ d +)?
使用JQuery Inputmask在限制/显示输入方面给了我想要的结果,但是它破坏了ngModel并将值设置为空,因此这对我来说不是一个选择,除非有人知道解决方法。
我可以对管道进行一些更改以获得我想要的结果吗?我该如何工作?
我在Angular 2.4上,我正在尝试使用PrimeNG的时间表,但我遇到了错误.如果您转到以下链接,您将看到计划的示例,如果向下滚动页面,还会看到文档:
http://www.primefaces.org/primeng/#/schedule
我遵循该文档(唯一的区别是我将"MyModel"更改为"CalendarComponent"),但是出现以下错误:
calendar.component.html:0:0引起的错误:this.schedule.fullCalendar不是函数
这是因为我需要安装和导入FullCalendar吗?我想可能是这种情况,但当我尝试导入它时,我得到了以下404:
https:// localhost:44301/node_modules/fullcalendar/fullcalendar 404()
尝试导入FullCalendar后,这是我的代码...
app.module.ts:
...
import { FullCalendar } from 'fullcalendar/fullcalendar';
import { ScheduleModule } from 'primeng/primeng';
import { CalendarComponent } from './calendar.component';
...
imports: [
...
FullCalendar,
ScheduleModule
],
declarations: [
...
CalendarComponent
],
...
Run Code Online (Sandbox Code Playgroud)
calendar.component.ts:
...
export class CalendarComponent implements OnInit {
events: any[];
headerConfig: any;
public constructor(
...
) { }
ngOnInit(): void {
this.events = [
{
"title": "All Day Event",
"start": "2016-01-01"
},
{
"title": "Long Event",
"start": …Run Code Online (Sandbox Code Playgroud) 我有一个带有表单的组件,可以将项目添加到列表中。成功将项目添加到列表后,我想使用form.resetForm();,但我无法找到一种简单的方法来知道该操作何时成功。我希望我可以订阅行动调度,但一直没能弄清楚。
我尝试了在网上找到的几种方法,但它们似乎都已经过时了。我确实通过向我的商店添加一个属性并订阅它来使其工作saving,但这对于本应非常简单的事情来说似乎是过多的工作。
有没有办法只订阅我的组件或容器内的内容而不重构我的 NGRX 逻辑?
以下是我的容器中将项目添加到列表中的代码:
addPosition(position: Position) {
this.store.dispatch(new fromStore.CreatePosition(position));
}
Run Code Online (Sandbox Code Playgroud)
行动:
export const CREATE_POSITION = '[Profile] Create Position';
export const CREATE_POSITION_FAIL = '[Profile] Create Position Fail';
export const CREATE_POSITION_SUCCESS = '[Profile] Create Position Success';
export class CreatePositionSuccess implements Action {
readonly type = CREATE_POSITION_SUCCESS;
constructor(public payload: any) {}
}
Run Code Online (Sandbox Code Playgroud)
影响:
@Effect()
createPosition$ = this.actions$.pipe(
ofType(positionsActions.CREATE_POSITION),
map((action: positionsActions.CreatePosition) => action.payload),
switchMap(position => {
return this.positionService
.addPosition(position)
.pipe(
map(newPosition => new positionsActions.CreatePositionSuccess(newPosition)),
catchError(error => of(new positionsActions.CreatePositionFail(error))) …Run Code Online (Sandbox Code Playgroud) 我有JQuery UI的datepicker工作在我的角度2应用程序,但它没有更新我的ngModel.我有一个名为的变量SeasonStartDate,我想更新到用户输入的任何日期.当我在日期选择器中选择日期时,例如10月31日,我的输入将填充10/31/2016,正如我所料,但未ngModel成功更新.
这是我的意见:
<input [ngModel]="SeasonStartDate" (ngModelChange)="updateSeasonStartDate($event)" class="form-control date-picker" id="SeasonStartDate" name="SeasonStartDate" type="text" autocomplete="off">
Date: {{SeasonStartDate}}
Run Code Online (Sandbox Code Playgroud)
我Date: {{SeasonStartDate}}在输入下面添加了以便我可以测试该值是否正在更新.
以下是我的组件中更新值的代码:
updateSeasonStartDate(updateSeasonStartDate: any) {
console.log(updateSeasonStartDate);
this.SeasonStartDate = updateSeasonStartDate;
}
Run Code Online (Sandbox Code Playgroud)
如果我删除了date-picker类(启动日期选择器所需的)并且我只是手动输入输入,SeasonStartDate将按预期更新,所以我知道我的其余代码工作,它只是最终破坏它的日期选择器.我怎样才能ngModel和JQuery UI Datepicker一起工作?这可能吗?我知道还有其他日期选择器专门用于Angular 2,但如果可能的话我更喜欢JQuery的版本.
我有一个选择下拉列表的以下代码:
<select id="UnitOfMeasurementId" name="UnitOfMeasurementId" [(ngModel)]="UnitOfMeasurementId">
<option *ngFor="let unit of UnitOfMeasurements" [ngValue]="unit.Value" [selected]="unit.Selected">{{unit.Text}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
UnitOfMeasurements数组中的每个项看起来像这样:
Selected: false
Text: "lb"
Value: "1"
Run Code Online (Sandbox Code Playgroud)
或这个:
Selected: true
Text: "kg"
Value: "3"
Run Code Online (Sandbox Code Playgroud)
[(ngModel)]="UnitOfMeasurementId"包含应选择的项的值.在此特定示例中,该值为3,因此应选择第3个项目.果然,当我检查它显示ng-reflect-selected="true"在正确项目上的元素时,实际上没有选择任何东西.如何才能获得列表中的正确项目以实际动态选择而不是仅添加ng-reflect-selected="true"属性?
angular ×8
ngfor ×2
arrays ×1
asp.net-mvc ×1
firefox ×1
fullcalendar ×1
java ×1
javascript ×1
jquery ×1
ngrx ×1
primeng ×1
sorting ×1
variables ×1