Angular 6 /Javascript - 在 (nglick) 中调用两个方法。组件和Js
Angular 6 /Javascript - Calling two methods in (nglick). Component and Js
我正在尝试在我的 click
事件中进行两次调用,其中一次用于我的组件,另一次用于我的 javascript 函数。下面是我的代码:.
事件点击Angular:
<button type="button" class="btn btn-primary" (click)="Plans(); " [attr.aria-expanded]="!isCollapsed"
aria-controls="collapseBasic">Test</button>
我的component.ts:
Plans(){
this.limparCombinadoList();
this.codCombinadoPadrao = "dgc" + this.value.toString();
this.service.combinadoTipoRisco(this.codCombinadoPadrao)
.subscribe(
result => {
this.coberturas = result.data;
this.premioFinalCobertura = result.premioFinalCombinado
this.processarDados(this.coberturas,this.premioFinalCobertura)
});
}
我的Javascript函数:
<script type="text/javascript">
function renderDiv(){
$.BrunoLeite.init('[data-animation]');
}
</script>
我的javascript文件
hs.onscroll-animation.js
(function($) {
'use strict';
$.BrunoLeite = {
/**
* Base configuration.
*
* @var Object _baseConfig
*/
_baseConfig: {
bounds: -100,
debounce: 50,
...
}}
将 alerta2
函数移动到组件内部并从 (click)
事件中调用它。
alerta2(){
alert("Bruno Leite")
}
(click)="Plans();alerta2();"
你可以调用用 ;
分隔的 2,像这样:
<button type="button" class="btn btn-primary" (click)="Plans(); alerta2();" [attr.aria-expanded]="!isCollapsed"
aria-controls="collapseBasic">Test</button>
此外,您必须在 component.ts
文件中移动函数 alerta
,更改:
function alerta2() {
alert("Bruno Leite")
}
至:
alerta2() {
console.log("Bruno Leite")
}
我正在尝试在我的 click
事件中进行两次调用,其中一次用于我的组件,另一次用于我的 javascript 函数。下面是我的代码:.
事件点击Angular:
<button type="button" class="btn btn-primary" (click)="Plans(); " [attr.aria-expanded]="!isCollapsed"
aria-controls="collapseBasic">Test</button>
我的component.ts:
Plans(){
this.limparCombinadoList();
this.codCombinadoPadrao = "dgc" + this.value.toString();
this.service.combinadoTipoRisco(this.codCombinadoPadrao)
.subscribe(
result => {
this.coberturas = result.data;
this.premioFinalCobertura = result.premioFinalCombinado
this.processarDados(this.coberturas,this.premioFinalCobertura)
});
}
我的Javascript函数:
<script type="text/javascript">
function renderDiv(){
$.BrunoLeite.init('[data-animation]');
}
</script>
我的javascript文件
hs.onscroll-animation.js
(function($) {
'use strict';
$.BrunoLeite = {
/**
* Base configuration.
*
* @var Object _baseConfig
*/
_baseConfig: {
bounds: -100,
debounce: 50,
...
}}
将 alerta2
函数移动到组件内部并从 (click)
事件中调用它。
alerta2(){
alert("Bruno Leite")
}
(click)="Plans();alerta2();"
你可以调用用 ;
分隔的 2,像这样:
<button type="button" class="btn btn-primary" (click)="Plans(); alerta2();" [attr.aria-expanded]="!isCollapsed"
aria-controls="collapseBasic">Test</button>
此外,您必须在 component.ts
文件中移动函数 alerta
,更改:
function alerta2() {
alert("Bruno Leite")
}
至:
alerta2() {
console.log("Bruno Leite")
}