我一直试图在单独的登录组件中以角度2实现Google登录.我无法使用Google https://developers.google.com/identity/sign-in/web/sign-in中提供的文档实施该文档
当我在index.html文件中声明我的脚本标记和google回调函数时,Google登录确实有效.但我需要一个单独的组件才能使用google按钮呈现登录并接收其中的回调以进一步处理为用户收到的访问令牌
我必须像这样显示欧元货币:583 €.
但是这个代码:
{{ price | currency:'EUR':true }}
Run Code Online (Sandbox Code Playgroud)
我知道€583,Angular核心中是否有任何选项可以将符号移动到右边?许多欧洲国家使用右边的符号(法国,德国,西班牙,意大利).
我正在尝试使用Karma和Jasmine来测试我的 Angular 7.2 应用程序。
它工作正常,除了一件事:当我单击测试名称时,它会刷新页面并再次重新执行所有测试。当出现故障并且我单击“规格列表”时也会发生同样的情况。我虽然单击测试名称应该只重做单击的测试,而“规范列表”单击应该只转到规范列表,显示哪些通过了,哪些没有通过。
知道为什么吗?
业力.conf.js :
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-mocha-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/gts-ui-extensions-rc'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['mocha', 'kjhtml'],
port: 4300,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true, …Run Code Online (Sandbox Code Playgroud) 我有一个Web应用程序项目,其中包含一个带有PHP API REST的文件夹和另一个包含Angular文件的文件夹.当我想将我的文件提交到BitBucket时,我可以提交除Angular文件夹下的文件以外的所有文件.
在SourceTree上同样的事情,我在这个文件夹下看不到任何变化.Angular是否正在使用"ng new angular-app"强制执行这种行为?我怎样才能解决这个问题 ?
我正在使用 ngx-translate 来翻译我的 Angular Web 应用程序,但似乎 ngx-translate 的功能存在问题getTranslation(language)。当它被调用时,它会改变当前的语言?暂时?然后我的组件没有以正确的语言显示。
export class InputRadioComponent extends FormComponentInput implements OnInit {
constructor(protected formDynamicS) {
}
public ngOnInit() {
this.translate.getTranslation("fr").subscribe(res => {
this.choose["fr"] = res['form-component']['choose-answer'];
});
this.translate.getTranslation("en").subscribe(res => {
this.choose["en"] = res['form-component']['choose-answer'];
});
this.translate.getTranslation("de").subscribe(res => {
this.choose["de"] = res['form-component']['choose-answer'];
});
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,就像this.translate.getTranslation("de")最后一次调用一样,我的组件始终以德语显示。我找到了一种解决方法,但这不是我想保留在我的代码中的东西。这是我的解决方法:
let languages: string[] = ["fr", "en", "de"];
languages.splice(languages.indexOf(this.translate.currentLang));
languages.push(this.translate.currentLang);
languages.forEach((language) => {
this.translate.getTranslation(language).subscribe(res => {
this.choose[language] = res['form-component']['choose-answer'];
});
});
Run Code Online (Sandbox Code Playgroud)
它允许我保留 currentLang,因为它将是最后一次调用 getTranslation
我想知道我们是否可以编写垂直文本,但是不使用任何轮换改变字符方向的技巧。
因此,我希望在may div中显示这样的文本,而不是“ START ”:
S
T
A
R
T
我可以使用“ break-word:word-break”并将元素的宽度设置为0,但是文本不会居中。字符将只向左对齐
不是重复的:垂直文本方向
我不想旋转文本,我想保留字符的方向
这是我能得到的代码示例:
.vertical-text {
font-size: 25px;
word-break: break-word;
width: 0;
display: flex;
justify-content: center;
padding: 0;
border: 1px solid rgba(0, 0, 0, 0.2);
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
body, html {
margin: 0;
padding: 0;
height: 100%;
width: 100%
}Run Code Online (Sandbox Code Playgroud)
<div class="vertical-text">START IT<div>Run Code Online (Sandbox Code Playgroud)
是否可以像这个例子一样绑定@HostBinding值?
@Input() user: User;
@HostBinding("class.temp") user.role == "Admin"
Run Code Online (Sandbox Code Playgroud)
我知道我可以这样做:
private _user: User;
@Input() set user(user: User) {
this._user = user;
this.temp = (this._user.role == "Admin");
}
@HostBinding("class.temp") temp: boolean;
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,如果我的用户更改了他的角色,则该组件中的值永远不会更新.这该怎么做 ?
我的 Angular 2 包中有一项服务,我想用这些行放在 NPM 上:
public showModal: Subject<any> = new Subject<any>();
public $showModal = this.showModal.asObservable();
public closeModal: Subject<any> = new Subject<any>();
public $closeModal = this.closeModal.asObservable();
public configModal: Subject<any> = new Subject<any>();
public $configModal = this.configModal.asObservable();
Run Code Online (Sandbox Code Playgroud)
主题变量的使用方式如下:myService.configModal(new ModalConfig());
Observables 与订阅一起使用来更新我的组件数据,显示或隐藏它。
这是我导出我的课程的 index.ts :
import {NgModule} from "@angular/core";
import {CommonModule} from "@angular/common";
import {ModalComponent} from "./lib/modal.component";
import {ModalService} from "./lib/modal.service";
@NgModule({
imports: [CommonModule],
declarations: [ModalComponent],
providers: [ModalService],
exports: [ModalComponent],
// bootstrap: [ModalComponent]
})
export class ModalModule {}
Run Code Online (Sandbox Code Playgroud)
如何在另一个应用程序中访问 ModalService?我希望我的服务也成为单例,所以我不能导出它并在我的组件中提供服务
我正在开发一个能够显示 Maven 项目的依赖项列表的插件。为了实现这一点,我读取了 pom.xml 文件并在控制台上打印数据以进行调试。这工作得很好,直到我从 JAR 文件中尝试它:我得到了一个 FileNotFoundException (对于 pom.xml 文件)