我已经创建了一个新的.net core 2.1应用程序angular template,之后我更新了要使用的项目Angular 6.
请注意,该项目与angular cli生成的项目几乎相同
我的项目将有很多组件和服务,因此我不想使用相对路径,而是希望能够使用非相对路径
import { WeatherService } from '../../services/weather.service'
Run Code Online (Sandbox Code Playgroud)
我希望能够使用非相对路径,如:
import { WeatherService } from '@app-services/weather.service'
Run Code Online (Sandbox Code Playgroud)
所以我补充道
"baseUrl": ".",
"paths": {
"@app-services/*": [ "src/app/services/*" ]
},
Run Code Online (Sandbox Code Playgroud)
进入 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"
],
"baseUrl": ".",
"paths": {
"@app-services/*": [ "src/app/services/*" ]
},
"lib": [
"es2017",
"dom"
]
}
} …Run Code Online (Sandbox Code Playgroud) Angular-CLI文档似乎没有包含对angular.json模式的完整引用,是否有地方可以找到可用选项的更完整列表?
我已输入数据用户详细信息first_name,last_name,phone_number和profile_pic但文件未上传其他表单数据如何上传其他表单数据文件?
用户form.component.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { UserService } from '../user.service';
import { FileUploader, FileSelectDirective } from 'ng2-file-upload/ng2-file-upload';
@Component({
selector: 'user-form',
templateUrl: './user-form.component.html',
styleUrls: ['./user-form.component.scss']
})
export class UserFormComponent {
angForm: FormGroup
router: Router;
constructor(private userservice: UserService, private fb: FormBuilder, private _route: Router) {
this.createForm();
this.router = _route;
}
createForm() {
this.angForm = this.fb.group({
first_name: ['', …Run Code Online (Sandbox Code Playgroud) 我们在CI管道中观察了随机业力测试.在每次运行中,不同的测试失败,有时它会通过,当它失败时会抛出此错误:
Uncaught TypeError: params.map is not a function thrown
有没有人受到类似的影响?
我已经在ng update @angular/cli命令的帮助下更新了我的angular-cli .之后,我遇到了Could not determine single project for 'server' target错误跟踪错误.
Could not determine a single project for the 'serve' target.
Error: Could not determine a single project for the 'serve' target.
at ServeCommand.getProjectNamesByTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:175:19)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:128:51)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:3:12)
at ServeCommand.runArchitectTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:121:16)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:34:25)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:7:71
Run Code Online (Sandbox Code Playgroud)
这种行为让我很困惑.有关更多信息,我也在package.json这里添加.
{
"name": "ProjectName",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": …Run Code Online (Sandbox Code Playgroud) 我正在学习更多关于角度6及其核心功能的内容,我对于应该使用角度6的文件夹结构感到困惑,我使用了不同教程的不同结构,例如traversymedia,udemy和list继续,每个人都使用不同的文件夹结构取决于项目.
这是我搜索和搜索后尝试过的内容
????src
????app
? ????layout
? ? ????admin
? ? ? ????breadcrumbs
? ? ? ????title
? ? ????auth
? ????pages
? ? ????animations
? ? ????authentication
? ? ? ????forgot
? ? ? ????lock-screen
? ? ? ????login
? ? ? ? ????with-bg-image
? ? ? ? ????with-header-footer
? ? ? ? ????with-social
? ? ? ? ????with-social-header-footer
? ? ? ????registration
? ? ? ????multi-step
? ? ? ????with-bg-image
? ? ? ????with-header-footer
? ? …Run Code Online (Sandbox Code Playgroud) 我正在学习Angular 6.
我以层次结构形式设计了我的应用程序结构,结构如下.
my_app
|- src
|- app
|- layout
|- admin-layout
|- admin-layout.module.ts
|- admin-layout.routing.ts
|- admin-layout.component.html
|- contacts
|- contact-list
|- contact-list.component.ts
|- contact-list.component.html
|- contacts.module.ts
|- transaction
|- amount-given
|- amount-given-list
|- amount-given-list.component.ts
|- amount-given-list.component.html
|- amount-given.module.ts
|- amount-given.routing.ts
|- amount-given.service.ts
|- transaction.module.ts
|- transaction.routing.ts
|- app.module.ts
|- app.component.html
|- app-routing.module.ts
Run Code Online (Sandbox Code Playgroud)
源代码和演示图可以在这里找到:https: //stackblitz.com/edit/angular-wcglvr
<a routerLink="/dashboard">Dashboard</a>
Run Code Online (Sandbox Code Playgroud)
是工作,/transaction/amount-given/amount-given-list/但不是从/contacts/contact-list.
由于源代码很长且层次分明,我在stackblitz上添加了演示插图.
我是Angular的初学者.我尝试用Angular材料选项卡做一些事情.我将标签部分添加到图像,但该部分无效.有谁知道如何将图像添加到角度材料选项卡.请查看我的附图,了解我尝试实现的目标.
我的代码部分:
<mat-tab-group mat-stretch-tabs class="example-stretched-tabs mat-elevation-z4">
<mat-tab label="First" style="background:url('/assets/img/school-01.png')"> Content 1 </mat-tab>
<mat-tab label="Second"> Content 2 </mat-tab>
<mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>
Run Code Online (Sandbox Code Playgroud)
CSS
.example-stretched-tabs {
max-width: 800px;
}
/* active tab */
.mat-tab-list .mat-tab-labels .mat-tab-label-active {
color:#0f2241;
background-color: #535353;
opacity: 1;
}
/* ink bar */
.mat-tab-group.mat-primary .mat-ink-bar {
background: none;
content: url('https://image.flaticon.com/icons/svg/60/60995.svg');
height: 10px;
}
Run Code Online (Sandbox Code Playgroud)
.TS
import {Component, ViewEncapsulation} from '@angular/core';
/**
* @title Tab group with stretched labels
*/
@Component({
selector: 'tab-group-stretched-example',
templateUrl: 'tab-group-stretched-example.html',
styleUrls: …Run Code Online (Sandbox Code Playgroud) 我想使用Spring Application的GET请求在Angular应用程序中显示HashMap.我试过这个:
春天代码:
@GetMapping("gateways")
public ResponseEntity<?> getGateways() {
Map<Integer, String> list = new HashMap<>();
list.put(1, "Bogus");
return ok(list.put);
}
Run Code Online (Sandbox Code Playgroud)
角度服务:
getContractGatewaysList(): Observable<Array<ContractGatewaysList>> {
return this.http.get<Array<ContractGatewaysList>>(environment.api.urls.contracts.getContractGateways);
}
Run Code Online (Sandbox Code Playgroud)
角度成分:
gateways: ContractGatewaysList[];
this.contractService.getContractGatewaysList()
.subscribe(value => {
if (value != null) {
this.gateways = value;
}
});
Run Code Online (Sandbox Code Playgroud)
接口:
export interface ContractGatewaysList {
id: number;
name: string;
}
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<div class="form-group gateway">
<div class="input-group-prepend">
<label for="merchant_id">Gateway</label>
</div>
<select class="custom-select" name="gateway" [(ngModel)]="contract.gateway" id="gateway" required>
<option selected>Please Select...</option>
<option [value]="gateway.id" *ngFor="let gateway of gateways">{{ gateway.name }}</option>
</select> …Run Code Online (Sandbox Code Playgroud) angular6 ×10
angular ×8
typescript ×4
angular-cli ×1
angular5 ×1
excel ×1
path ×1
sass ×1
spring ×1
tabs ×1