Angular 2框架是否包含Http响应状态代码作为常量?
因此,我可以编写HttpStatus.NOT_FOUND而不是写404.
谢谢!
在我的Angular 2应用程序中,我有以下代码:
import { Observable } from 'rxjs/Rx';
import { Subscription } from '@angular-cli/ast-tools/node_modules/rxjs/Rx';
...
private broadcastDataSubject: BehaviorSubject<Event>;
...
let sub: Subscription = this.broadcastDataSubject.asObservable().subject(event).subscribe(() => this.bla());
Run Code Online (Sandbox Code Playgroud)
问题出在最后一行,代码不会因为:
"类型'订阅'不能指定为"订阅"类型.存在两个具有此名称的不同类型,但它们是无关的."
我的第二个项目中有相同的代码,运行没有问题.
在我的项目中,我想使用Spring Boot
和Angular 2.
Spring Boot App
由Spring Initializer完成 .Angular 2 App
由Angular CLI
工具(ng new myfrontendapp
)完成在Angular 1
你可以把你index.html
变成公共文件夹中.
在Angular 2
该index.html
中生成src
文件夹,我想保持这种结构.
我的问题是我应该怎么做才能index.html
看到Spring Boot
并保持生成的结构Angular CLI.
谢谢你的回答.
当我访问keycloak管理控制台(!远程)并创建客户端时:
keycloak OIDC JSON没有公钥
我希望在JSON中有类似的东西:
"realm-public-key": "MIIBIjANBg....
Run Code Online (Sandbox Code Playgroud) 我有以下 btn-group:
<div class="btn-group">
<label class="btn btn-primary" [(ngModel)]="type" btnRadio="{{myType.A}}" name="A" ngDefaultControl>A</label>
<label class="btn btn-primary" [(ngModel)]="type" btnRadio="{{myType.B}}" name="B" ngDefaultControl>B</label>
</div>
Run Code Online (Sandbox Code Playgroud)
MyType 是一个枚举:
export enum MyType {
A, B
}
Run Code Online (Sandbox Code Playgroud)
这是组件:
@Component({
selector: 'add-record',
templateUrl: './add-record.component.html',
styleUrls: ['./add-record.component.css']
})
export class AddRecordComponent implements OnInit {
type: MyType;
myType = MyType;
constructor() { }
ngOnInit() {
this.type = MyType.A;
}
}
Run Code Online (Sandbox Code Playgroud)
可以看到type的初始值是 MyType.A因此我希望第一个按钮处于活动状态,但事实并非如此。
我预计:
我有:
我有MyService被注入ComponetA和ComponetB。
是否可以找出MyService.myMethod()是从哪个组件调用的?
@Injectable()
export class MyService {
public myMethod(): void {
console.log('called from component: ' + component);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建事件广播服务。
这是我想要实现的基本概念:
export enum Event {
EVENT_A,
EVENT_B, ...
}
@Injectable()
export class BroadcastService {
private broadcastSubject: Subject<Event> = new Subject<Event>();
public next(event: Event): void {
return this.broadcastSubject.next(event);
}
public subscribe(event: Event, componentCall: Function): void {
this.broadcastSubject.subscribe(
eventValue => {
if(event === eventValue) {
componentCall(); // not possible to call component's method like this
}
}
);
}
}
Run Code Online (Sandbox Code Playgroud)
我知道我不能从这样的服务中调用组件的方法。我必须以某种方式返回observable,并从组件中调用它。我不确定如何实现这一目标。
感谢您的任何建议。
解
感谢AngularFrance,这是BroadcastService的解决方案:
@Injectable()
export class BroadcastService {
private broadcastSubject: BehaviorSubject<Event> = new BehaviorSubject<Event>(0);
public next(event: Event): void …
Run Code Online (Sandbox Code Playgroud) 我有 Spring Boot 应用程序,我使用keycloak作为身份验证。提供者。
对于我的领域,我已将FACEBOOK 或 GOOGLE设置为身份提供者。
我想知道如何找出用户使用的身份提供者 - 不是通过 keycloak 管理控制台,而是在运行时。
例如。:
用户 A - 脸书
用户 B - 脸书
用户 C - 谷歌
嗨,在我的Angular 2应用程序中,我正在使用ng2-file-upload:
<input type="file" ng2FileSelect [uploader]="uploader" multiple (change)="onChange($event)">
Run Code Online (Sandbox Code Playgroud)
我想在我的javascript代码中从uploader或event对象创建一个image对象的实例.不知何故喜欢:
public onChange(event) {
let item = this.uploader.queue[0];
let img = new Image();
img.src = item.SOMETHING;
OR
img.src = event.SOMETHING;
}
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做.
我正在尝试使用以下方法在Mac上安装OpenCV3:
brew tap homebrew/science
brew install opencv3 --HEAD --with-java
Run Code Online (Sandbox Code Playgroud)
我希望罐子库在:
/usr/local/Cellar/opencv/3.3.0_3/share/OpenCV
Run Code Online (Sandbox Code Playgroud)
但是整个项目中都没有jar。
(我还-DBUILD_opencv_java=ON
通过添加了标志brew edit opencv3
)
angular ×7
keycloak ×2
spring-boot ×2
angular-cli ×1
homebrew ×1
macos ×1
opencv ×1
typescript ×1