Angular 6 / Javascript-在(nglick)中调用两个方法。组件和Js

时间:2018-12-14 13:49:47

标签: javascript angular html5 angular6 angular7

我正在尝试在click事件中进行两次调用,这些调用分别是我的组件和javascript函数。下面是我的代码:。

事件点击角度:

<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,
...

}}

2 个答案:

答案 0 :(得分:1)

$fromYear = 2016; $fromMonth = 3; $toYear = 2018; $toMonth = 9; $from = Carbon::parse($fromYear.'-'.$fromMonth); $to = Carbon::parse($toYear.'-'.$toMonth); $diff = $from->diffForHumans($to, true, false, 6); "2 years 6 months" 函数移到组件内部,并从alerta2事件中调用它。

(click)

答案 1 :(得分:1)

您可以用.card{ margin: 0 auto; padding:4rem; margin: 4rem; font-size: 1.6rem; box-shadow: 0 2rem 2rem rgba(0,0,0,.6); background-color: $color-grey-light-1; transition: all .2s; transform:skewX(-12deg); &__details { transform: skewX(12deg); } &__header{ display: inline-block; font-size: 1.8rem; margin-bottom: 1rem; } &:hover{ transform:skewX(-12deg) translateY(-2px); cursor: pointer; } } 分隔两个,就像这样:

;

此外,您必须将函数<button type="button" class="btn btn-primary" (click)="Plans(); alerta2();" [attr.aria-expanded]="!isCollapsed" aria-controls="collapseBasic">Test</button> 移动到alerta文件中,并进行以下更改:

component.ts

收件人:

function alerta2() {
    alert("Bruno Leite")
}