我有一个页面运行在“ http://localhost:4200/assignmentForAudit ”,用户界面看起来像
当我单击删除按钮时,数据将被删除,但页面不会刷新。我试着把 this.router.navigate(['/assignmentForAudit']);在删除操作后放置,但它没有刷新页面。我怎样才能实现这种刷新方法以便删除数据?
在component.ts中删除的方法
onDelete(nas:any){
this.assignmentAudit.id=nas.assignmentAudit[0].id;
console.log(this.assignmentAudit.id);
if(window.confirm('Are sure you want to delete this item ?')){
this.assignmentAuditService.deleteGroupFromSelection(this.assignmentAudit.id)
.subscribe(
data => {
console.log(data);
},
error => console.log(error));
}
this.router.navigate(['/assignmentForAudit']);
}
Run Code Online (Sandbox Code Playgroud)
assignment-audit.service.ts类方法调用api操作
deleteGroupFromSelection(id: number): Observable<any> {
return this.http.delete(`${this.baseUrl}/${id}`, { responseType: 'text' });
}
Run Code Online (Sandbox Code Playgroud)
删除操作工作正常,但问题是页面不刷新。
enter code here
getHospital(term: string = null): Observable<Hospitals[]> {
let items = this.getHospitals1();
if (term) {
items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
}
return items.pipe(delay(500));;
}
getHospitals1() : Observable<Hospitals[]>{
return this.http.get<Hospitals[]>('https://my-json-server.typicode.com/monsterbrain/FakeJsonServer/hospitals')
}
Run Code Online (Sandbox Code Playgroud)
当我添加过滤器时发生错误 这是使用 ng-select 的下拉列表的代码。它基于基于文本的搜索,这里使用 angular7 和 rxjs 6
我的 Angular 6 应用程序遇到问题,我正在将其分解为更小的模块。最初所有内容都导入到 AppModule 中,并且运行得很好,但它是一个巨大的文件,测试过于复杂。
我遇到的问题基本上是为应用程序中的一些常用服务创建共享模块。ng build运行良好,因此似乎构建正常,但是当我提供应用程序时,我收到错误“ConfigService.foo()”不是函数!我显然在将共享服务分组到共享模块中做错了事情。
这是一些代码:
共享模块
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
import { Injectable, OnInit, NgModule } from '@angular/core';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import * as $ from 'jquery';
import { PipeModule } from './pipes/pipes.module';
import { ConfigService } from "./config.service";
@NgModule({
imports: [
PipeModule
],
declarations: [
],
exports: [
PipeModule
],
providers: [
ConfigService
]
})
export class SharedModule {
static forRoot() { …Run Code Online (Sandbox Code Playgroud) 感谢@rijin 重写代码:reducers/index2.ts:
import { ActionReducerMap } from "@ngrx/store";
import { userReducer, UserState } from "./user2.reducer";
import { cartReducer, CartState } from "./cart2.reducer";
interface AppState {
user: UserState;
cart: CartState;
}
export const reducers2: ActionReducerMap<AppState> = {
user: userReducer,
cart: cartReducer
};
Run Code Online (Sandbox Code Playgroud)
用户处的编译错误:userReducer:
Type '(appUserState: UserState, action: any) => User' is not assignable to type 'ActionReducer<UserState, Action>'.
Property 'user' is missing in type 'User' but required in type 'UserState'.
Run Code Online (Sandbox Code Playgroud)
/reducers/user.ts:
export class User {
uName: string;
isAdmin: boolean;
ts: string; …Run Code Online (Sandbox Code Playgroud) 在 Angular 7 项目中,我有以下 Typescript 界面:
export interface Request {
expand: string;
limit: number;
}
Run Code Online (Sandbox Code Playgroud)
然后我按如下方式使用它:
let request: Request = { expand: 'address' };
Run Code Online (Sandbox Code Playgroud)
我收到错误,因为我没有设置limit...
如何limit在界面中设置可选?
我需要在我的角度项目的组件中添加脚本(cdn)。
在其中
// Start: for drop box
var dbx = new Dropbox({ accessToken: 'A4fRBcFXasdkpAAAAAdgfdfgdfgAAAAAZBlQ9MJNe81yrTLOCioH-7Ty083asdEQSqTD97s7mLIJH0V', fetch: fetch });
dbx.filesListFolder({ path: '' })
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// End: for dropbox```
Run Code Online (Sandbox Code Playgroud)
addJsToElementDropbox(src: string, type: string, id: string, key: string): HTMLScriptElement {
let script:any = document.createElement('script');
script.type = type;
script.src = src;
script.id = id;
this.renderer.appendChild(document.body, script);
return script;
}```
Run Code Online (Sandbox Code Playgroud)
这是在 DOM 中创建的脚本
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs"></script>
我的需要是在 DOM 中创建一个这样的脚本
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="my-key"></script>
我希望我的日期、时间采用角度格式的 EPOCH 格式。谁能帮助我如何获取 EPOCH 格式的日期?
let UCCdateformated = formatDate(today, 'yyyy-MM-dd', 'en-US', '+0530');
console.log("UCCdateformated ",UCCdateformated);
Run Code Online (Sandbox Code Playgroud) 我正在创建一个 Angular 7 应用程序,它利用 Jira 问题收集器将问题直接提交到各自的项目。
当我按照现在的方式构建应用程序时,什么也没有发生。当我直接将代码从方法“submitIssue”移动到“ngOnInIt”下时,会出现问题收集器对话框。代码片段应该添加到哪里?
任何帮助将不胜感激。谢谢你!
// Requires jQuery!
jQuery.ajax({
url: "https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com",
type: "get",
cache: true,
dataType: "script"
});
window.ATL_JQ_PAGE_PROPS = {
"triggerFunction": function(showCollectorDialog) {
//Requires that jQuery is available!
jQuery("#myCustomTrigger").click(function(e) {
e.preventDefault();
showCollectorDialog();
});
}};
Run Code Online (Sandbox Code Playgroud)
这是我的数组,它在问题收集器组件上填充了不同项目和按钮的卡片。
export const PROJECTS: any = [
{
id: 1,
title: 'Project Title',
/** The url is taken directly from the issue collector section within the Jira project. Link below is modified
* for security purposes. */
url: 'https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com' …Run Code Online (Sandbox Code Playgroud) 我正在使用 ng-multiselect-dropdown。我想将其宽度设置为 100pt。
我已经尝试过使用一些CSS
.multiselect-dropdown {
widht:100pt;
}
.multiselect-dropdown .dropdown-btn {
widht:100pt;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试记录我的角度应用程序中访问的每个页面。
我的路线是这样的:
const routes: Routes = [
{ path: ':id', component: AppComponent}
];
Run Code Online (Sandbox Code Playgroud)
我的 app.component .ts onInit:
ngOnInit() {
console.log(this.router.url);
}
Run Code Online (Sandbox Code Playgroud)
当我访问 /testing123 时
我希望它记录“/testing123”,但在没有传递 ID 的情况下记录“/”。