我试图在用户注册后显示警报.我已经尝试过调试并且明白它总是会出现错误功能(当用户注册成功并且用户已经存在时).
以下是我的代码.我无法理解为什么总是会出错.任何帮助都表示赞赏,因为我长期坚持这一点.提前致谢.
1)警报组件
import { AlertService } from './../../shared/services/alert.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-alert',
templateUrl: './alert.component.html',
styleUrls: ['./alert.component.css']
})
export class AlertComponent {
private _alertService;
private message: any;
constructor(alertService: AlertService) {
this._alertService = alertService;
}
ngOnInit() {
this._alertService.getMessage().subscribe(message => { this.message = message; });
}
}
Run Code Online (Sandbox Code Playgroud)
2.Alert模板
<div *ngIf="message" [ngClass]="{ 'alert': message, 'alert-success': message.type === 'success',
'alert-danger': message.type === 'error' }">{{message.text}}</div>
Run Code Online (Sandbox Code Playgroud)
3)注册模板
<div class="container">
<h2>Register</h2>
<form name="form" (ngSubmit)="f.form.valid && register()" #f="ngForm" novalidate>
<div class="form-group" [ngClass]="{ …Run Code Online (Sandbox Code Playgroud) 这是我点击表格时的UsersList组件.将打开一个新页面
更改用户值并保存后,保存的值不会首次反映在网格中.但是,当我再次进行相同的操作时,它会被反映出来.
以下是我的保存用户代码
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { UserService } from './../../shared/services/user.service';
import {User} from './../../shared/models/user';
@Component({
selector: 'app-user-add-edit',
templateUrl: './user-add-edit.component.html',
styleUrls: ['./user-add-edit.component.css']
})
export class UserAddEditComponent implements OnInit {
private user: User;
private id:Number;
constructor(private userService: UserService, private route: ActivatedRoute,private router: Router) { }
ngOnInit() {
this.id = Number(this.route.snapshot.params['id']);
if (this.id) {
this.userService.read(this.id).subscribe(
users => this.user = users,
err => {
console.log(err);
}
);
}
}
saveUser(){
this.userService.update(this.user.client,this.user.firstName,this.user.lastName,this.user.id,this.user.key).subscribe( …Run Code Online (Sandbox Code Playgroud) 我这里有一个代码示例.
struct node {
int data;
struct node *link;
};
static struct node *first = NULL;
Run Code Online (Sandbox Code Playgroud)
如果有人能够对我在下面关于静态这个词的使用的问题提出一些看法,那就太棒了.
关键字static在上面的代码中做了什么?
普通结构和静态结构有什么区别?
我刚刚开始学习java,当我遇到界面时,我看到了以下代码:
interface Callback {
void callback(int param);
}
Run Code Online (Sandbox Code Playgroud)
class Client implements Callback {
public void callback(int p) {
}
}
Run Code Online (Sandbox Code Playgroud)
为什么将实现的接口方法声明为public?
我已经在角度调用了单个服务,但从未调用多个服务.在我附加的图像中,要求是将客户端和组值添加到名为clientGroup Xref的表中.另外客户端,Clientrole,ClientKey在不同的表中(ClientService会这样做).我想知道如何在创建按钮单击的同时调用clientservice和clientgroup Xref服务.
This is the code I tried so far
import { Router } from '@angular/router';
import { AuthService } from './auth.service';
import {PESAuthService} from './pes_auth.service';
import { Component, OnInit, Injectable } from '@angular/core';
import { Http, Request, RequestMethod, RequestOptions, Headers, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import {Client} from './../../shared/models/Client';
@Injectable()
export class ClientService implements OnInit {
private appContent = 'application/json';
private _router: Router;
private baseUrl = 'http://localhost:5050/api/v1/';
//Constructor to initialize authService to authenticate …Run Code Online (Sandbox Code Playgroud) 如何编写一个程序来查找给定数字后的n个素数?例如,在100之后的前10个素数,或在1000之后的前25个素数.编辑:下面是我尝试的.我正在以这种方式获得输出,但是我们可以在不使用任何素性测试函数的情况下进行输出吗?
#include<stdio.h>
#include<conio.h>
int isprime(int);
main()
{
int count=0,i;
for(i=100;1<2;i++)
{
if(isprime(i))
{
printf("%d\n",i);
count++;
if(count==5)
break;
}
}
getch();
}
int isprime(int i)
{
int c=0,n;
for(n=1;n<=i/2;n++)
{
if(i%n==0)
c++;
}
if(c==1)
return 1;
else
return 0;
}
Run Code Online (Sandbox Code Playgroud)