因为我是角2和学习的新手。
我使用链接https://www.tutorialspoint.com/typescript/typescript_environment_setup.htm引用了angular 2教程
在这里,我知道打字稿正在被编译为javascript。
并且在对angular 2应用进行编码时,我在tsconfig.json文件中发现如下所示:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,“ target”:“ es5”规范表明该打字稿已转换为es5标准,即ECMAScript2009和“ lib”:[“ es2017”,“ dom”]规范表明其使用了es2017库。
任何人都可以澄清角2的移植概念吗?
我们可以将“ target”:“ es5”更改为es6即ECMAScript2015吗?
以及“ lib”:[“ es2017”,“ dom”]到底指定了什么?
我正在关注PrimeNg示例.这里是一个Plunker.如何在下拉列表中预先选择一些值.
<p-multiSelect [options]="cities" [(ngModel)]="selectedCities"></p-multiSelect>
Run Code Online (Sandbox Code Playgroud) 我有一个带有signlar 2.2.2的angular 2应用程序,这是我的signalr连接服务类..
import { Injectable, Inject } from "@angular/core";
import { Subject } from "rxjs/Subject";
import { Observable } from "rxjs/Observable";
/**
* When SignalR runs it will add functions to the global $ variable
* that you use to create connections to the hub. However, in this
* class we won't want to depend on any global variables, so this
* class provides an abstraction away from using $ directly in here.
*/
export class SignalrWindow extends Window …Run Code Online (Sandbox Code Playgroud) 我想要的是:如果p1或p2被锁定,所选选项保持不变;但下面的代码工作不正确。所选选项仍然发生变化。有人能给我一些建议吗?
<mat-form-field style="text-align: center; width: 25%;">
<mat-select #singleSwap [(value)]="categoryProduct.sort"
(selectionChange)="singleSwapSelectionChange(singleSwap.value,categoryProduct.id)">
<mat-option *ngFor="let option of options" [value]="option">
{{ option }}
</mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
singleSwapSelectionChange(currentSelection: number, id: number) {
let p1 = this.categoryProducts.find(p => p.sort === currentSelection);
let p2 = this.categoryProducts.find(p => p.id === id);
if (p1.is_locked || p2.is_locked) {
console.log('locked!')
return;
}
p1.sort = p2.sort;
p2.sort = currentSelection;
Run Code Online (Sandbox Code Playgroud) 我想做一件奇怪的事情,因为角度正在抱怨。有没有人尝试在 Angular 4 上的 html 代码中混合插值和三元
在输入上,我尝试使用三元注入 matToolTip,同时使用管道将字符串转换为显示,如下所示:
<input
typeaheadOptionField="name"
typeaheadOptionsLimit="15"
placeholder="{{ 'odal.selectPlaceholder' | translate }}"
class="form-font-size form-control"
style="vertical-align: middle"
type='text'
[matTooltip]="!isRefAutorized ? {{ 'modal.refSelect' | translate }} : null"
(keyup.enter)="createStyle(styleCode.value)"
#styleCode
/>
Run Code Online (Sandbox Code Playgroud)
但有角度的抱怨
Parser Error: Got interpolation ({{}}) where expression was expected at column 18 in [!isRefAutorized ? {{ 'modal.selectPlaceholder' | translate }} : null]
it works fine when I do just:
[matTooltip]="!isRefAutorized ? 'not authorized' : null"
Run Code Online (Sandbox Code Playgroud) 我使用日历输入如下。
<p-calendar maxDate="dateTime" showTime="true" hourFormat="12" showButtonBar="true" [(ngModel)]="dateTime" name="timeOfUse" required #timeOfUse="ngModel">
</p-calendar>
Run Code Online (Sandbox Code Playgroud)
我想在此日期选择器中禁用将来的日期。它可能是一个简单的属性,但我无法弄清楚。感谢任何帮助
从我的代码示例中。
tabs: object = [
{ key: 'tab1', value: 'tab1' },
{ key: 'tab2', value: 'tab2' },
{ key: 'tab3', value: 'tab3' },
];
Run Code Online (Sandbox Code Playgroud)
<div [ngSwitch]="my_tab">
<div *ngFor="let tab of tabs" *ngSwitchCase="'{{ tab.key }}'">
{{ tab.value }}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我总是收到此代码的错误。这该怎么做?
我刚开始使用Angular和NativeScript,对于我的生活,我无法弄清楚为什么我无法获得对组件的引用.
首先,我使用以下命令生成初始文件:tns create Test -ng.
接下来,我创建以下文件结构:
App_Resource
components
---app
------app.component.ts
---create
------create.component.ts
------create.component.html
app.module.ts
app.routing.ts
main.ts
Run Code Online (Sandbox Code Playgroud)
这是app.component.ts
import { Component } from "@angular/core";
import { Router } from "@angular/router";
@Component({
selector: "my-app",
template: "<page-router-outlet></page-router-outlet>"
})
export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)
这是create.component.ts
import { Component } from "@angular/core";
import { Location } from "@angular/common";
import { Router } from "@angular/router";
import * as AppSettings from "application-settings";
@Component({
selector: "create",
templateUrl: "./components/create/create.component.html",
})
export class CreateComponent …Run Code Online (Sandbox Code Playgroud) 使用RxJS,我想调用两个不同的异步操作,这些操作可能会也可能不会返回null.他们也可能无限期地完成任务.
我想实现以下目标:
null,则返回null.我想我可以完成前两个简单如下:
const bothOperations = merge(callA(), callB());
const firstSuccess = bothOperations.first(res => res !== null);
return firstSuccess;
Run Code Online (Sandbox Code Playgroud)
但是,我如何获得第三种可能性呢?
以前,我不得不columnDefs使用内置的分组功能在没有 Angular 组件的情况下渲染 ag-grid 单元格。
colDef = [
{
headerName: 'HeaderName',
field: 'a',
editable: false,
cellRenderer: 'group',
...
},
Run Code Online (Sandbox Code Playgroud)
现在我尝试使用 Angular 组件来渲染 ag-grid 单元格,cellRendererFramework但这让我失去了分组功能。具有展开/折叠功能的树组值不再起作用。
colDef = [
{
headerName: 'HeaderName',
field: 'a',
editable: false,
cellRendererFramework: MyCustomCellRendererComponent,
...
},
Run Code Online (Sandbox Code Playgroud)
我需要手动设置分组吗?
我也试过使用groupRowInnerRenderer, innerRendererFramework。
angular ×9
javascript ×3
primeng ×2
ag-grid ×1
asp.net ×1
asynchronous ×1
c# ×1
ionic3 ×1
nativescript ×1
rxjs ×1
signalr ×1
typescript ×1