2017-04-14 14 views
5

मैंने हाल ही में अपने कोणीय ऐप को कोणीय 2.4.0 से कोणीय 4.0.0 तक अपग्रेड किया है। मैंने इस link का पालन किया है यह बिना किसी त्रुटि के संकलित है, केवल 3 चेतावनियां देता है। यहां चेतावनी का स्क्रीनशॉट संलग्न है। enter image description here लेकिन एनीमेशन काम नहीं कर रहा है। कृपया जांचें कि मैं क्या खो रहा हूं। अग्रिम धन्यवाद।कोणीय 4 अपग्रेड एनीमेशन काम नहीं कर रहा

package.json

"dependencies": { 
    "@angular/animations": "^4.0.0", 
    "@angular/common": "^4.0.0", 
    "@angular/compiler": "^4.0.0", 
    "@angular/compiler-cli": "^4.0.0", 
    "@angular/core": "^4.0.0", 
    "@angular/forms": "^4.0.0", 
    "@angular/http": "^4.0.0", 
    "@angular/platform-browser": "^4.0.0", 
    "@angular/platform-browser-dynamic": "^4.0.0", 
    "@angular/platform-server": "^4.0.0", 
    "@angular/router": "^4.0.0", 
    "angular2-modal": "2.0.2", 
    "core-js": "2.4.1", 
    "font-awesome": "4.7.0", 
    "jquery": "3.2.1", 
    "ng2-translate": "2.5.0", 
    "rxjs": "5.2.0", 
    "typescript": "^2.2.2", 
    "web-animations-js": "^2.2.2", 
    "zone.js": "0.7.4" 
    }, 

app.component.ts

import { Component } from '@angular/core'; 
import { Router, ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router'; 
import { BaseComponent } from '../base/base.component'; 
import { ViewContainerRef, ViewEncapsulation } from '@angular/core'; 
import { trigger, transition, style, animate, state } from '@angular/animations'; 
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 


@Component({ 
    selector: 'verification', 
    templateUrl: 'app.component.html', 
    providers: [BaseComponent], 
    animations: [ 
     trigger('trans', [ 
      // What happens when toggleState is true 
      // state('true' , style({ opacity: 1, transform: 'translateX(0)', offset: 0 })), 
      state('true', style({ transform: 'translateY(0)' })), 
      // What happens when toggleState is false 
      // state('false', style({ opacity: 0, transform: 'translateX(100%)', offset: 0, position:'absolute', right:-9999 })), 
      state('false', style({ transform: 'translateY(20%)' })), 
      // transition 
      transition('0 => 1', animate('0.2s 100ms ease-in')), 
      transition('1 => 0', animate('0.3s 25ms ease-out')) 
     ]) 
    ] 
}) 
export class VerificationComponent { 
    public verifySuccess:boolean; 
    constructor(private router: Router, private route: ActivatedRoute, private base: BaseComponent) { 
     this.verifySuccess = true; 
    } 

} 

app.component.html

<div class="clearfix"> 
    <div class="backstretch"> 
    </div> 
    <div class="vefification"> 
     <div class="verification-content"> 
      <div class="verification-main p-20" [@trans]="verifySuccess"> 
        <div *ngIf="verifySuccess">           
         <h3>YOU'RE ALL SET</h3>      
         <div class="form-group"> 
          <button class="btn-resend-email" type="submit" (click)="verifySuccess=true">RESEND EMAIL</button> 
         </div> 
        </div>     
      </div> 
     </div> 
    </div> 
</div> 

app.modulte.ts

import { NgModule }  from '@angular/core'; 
import { BrowserModule, Title } from '@angular/platform-browser'; 
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 
@NgModule({ 
    imports:  [ BrowserModule, 
        BrowserAnimationsModule, 
        BootstrapModalModule, 
        ], 
    declarations: [ //components 
        VerificationComponent, 
        ] }) 

export class AppModule { } 

उत्तर

2

मैंने हाल ही में इसी तरह के मुद्दे पर भाग लिया। और मेरे राज्यों को बदलकर इसे हल करने में कामयाब रहा - जो एनिमेशन को ट्रिगर करता है - तारों के लिए।

मैं 0 और 1 का उपयोग राज्यों के रूप में 2.X में एनीमेशन ट्रिगर करने के लिए कर रहा था। 4.X में अपग्रेड करने के बाद मुझे त्रुटियां नहीं मिलीं, लेकिन यह एनिमेशन को ठीक से ट्रिगर नहीं करेगा। केवल तारों पर स्विच करने से यह फिर से काम करता है। चूंकि आप बूलियन का उपयोग कर रहे हैं, इसलिए मैं तारों पर स्विच करने का प्रयास करूंगा और यह आपके लिए फिर से काम करना शुरू कर सकता है।

तो this.veryfySuccesstrue/false के बजाय 'no'/'yes' हो सकता है। आपको 0 => 1 से no => yes के साथ-साथ trigger के भीतर घोषणाओं में transition को एनीमेशन में अपडेट करने की आवश्यकता होगी।

+0

धन्यवाद यह मेरे लिए भी काम करता है। मैंने राज्यों को राज्यों के समान मूल्यों को स्ट्रिंग और असाइन करने के लिए बदल दिया। तो यह काम किया। मुझे लगता है कि इसे बुलियन मूल्यों और राज्यों के साथ काम करना चाहिए, मुझे नहीं पता कि यह बुलियन मूल्यों के साथ क्यों काम नहीं करता है। –

+0

मुझे खुशी है कि इससे मदद मिली। मैं मानता हूं कि इसे संख्या/बूलियन के साथ काम करना चाहिए। लेकिन मुझे आश्चर्य हुआ कि उन्होंने अपने अपग्रेड नोट्स में इसका जिक्र नहीं किया। –

0

आप अपने app.component.ts में फिर से आयात करने BrowserAnimationsModule जरूरत नहीं है। आपको इसे अपने NgModule में एक बार घोषित करना चाहिए। आपके पास शायद आपके टेम्पलेट में कुछ टाइपो हैं क्योंकि आपका अपग्रेड ठीक लगता है।

+0

हाँ, लेकिन हमने app.component.ts से ब्राउज़र एनीमेशन मॉड्यूल पर टिप्पणी की है लेकिन फिर भी समस्या एक ही रहती है –

+0

@ प्रवीण मिश्रा हम्म, क्या आप अपना सत्यापन.compontent.html दिखा सकते हैं? – brijmcq

+0

सत्यापन.component.html app.component.html के समान है, जबकि संपादित करें मैं टेम्पलेट बदलने के लिए भूल गया यूआरएल –

संबंधित मुद्दे