javascript - Angular 4 : Build to prod: Property is private and only accessible within class -
i'm using angular 4 , i'm running : ng build --prod
i'm catching :
ng build --prod global angular cli version (1.2.2) greater local version (1.0.0). local angular cli version used. disable warning use "ng set --global warnings.versionmismatch=false". hash: 7fce5d10c4c3ac9745e8 time: 68351ms chunk {0} polyfills.7790a64cc25c48ae62ea.bundle.js (polyfills) 177 kb {4} [initial] [rendered] chunk {1} main.f10680210e9e45ed33cc.bundle.js (main) 382 kb {3} [initial] [rendered] chunk {2} styles.d2e6408caea42ccabf99.bundle.css (styles) 175 bytes {4} [initial] [rendered] chunk {3} vendor.fc69ec31f7ef40b5fffb.bundle.js (vendor) 5.9 mb [initial] [rendered] chunk {4} inline.91747411075ce6c7f438.bundle.js (inline) 0 bytes [entry] [rendered] error in ng:///d:/sources/dotnet/nextgcclientweb/src/app/login/login.component.html (11,3): property 'activatedroute' private , accessible within class 'login component'. error in ng:///d:/sources/dotnet/nextgcclientweb/src/app/login/login.component.html (11,3): property 'activatedroute' private , accessible within class 'login component'.
this error seems strange :
error in ng:///d:/sources/dotnet/nextgcclientweb/src/app/login/login.component.html (11,3): property 'activatedroute' private , accessible within class 'login component
the indicated component in error follwoing :
import { component } '@angular/core'; import { router, activatedroute, params } '@angular/router'; import { http, response } '@angular/http'; import { sessionservice } './../../shared/service'; import { user } './../../model'; @component({ selector: 'login', templateurl: './login.component.html', styleurls: ['./login.component.css'] }) export class logincomponent { error: string; email: string; password: string; stayconnected: boolean; constructor ( private sessionservice: sessionservice, private router: router, private activatedroute: activatedroute ) { if (activatedroute.snapshot.params['keywording']) { this.sessionservice.loginwithfinalization(activatedroute.snapshot.params['keywording']); } } login() { this.sessionservice.login(this.email, this.password, this.stayconnected).subscribe( () => { if (this.sessionservice.pagerequestedinunauthenticated == null) { this.router.navigate(['/welcome']); } else { this.router.navigate([this.sessionservice.pagerequestedinunauthenticated]); } }, (error: response) => this.error = error.json() ); } }
the html view:
<div id="divlogin"> <h1>se connecter</h1><br> <i class="fa fa-envelope-o fa-lg" id="iconemail"></i> <input type="text" id="email" [(ngmodel)]="email" (keyup.enter)="login()" class="form-control" placeholder="adresse email" autofocus /> <i class="fa fa-lock fa-lg" id="iconpassword"></i> <input type="password" id="password" [(ngmodel)]="password" (keyup.enter)="login()" class="form-control" placeholder="mot de passe" /> <button (click)="login()" class="btn btn-primary btn-block btn-lg">connexion</button> <span id="containerstayconnected" title="non implémenté"><input type="checkbox" id="stayconnected" [(ngmodel)]="stayconnected" /><label for="stayconnected">restez connecté</label></span> <a id="forgetpassword" title="non implémenté">mot de passe oublié</a><br><br><br> <a routerlink="/inscription">s'inscrire</a><br> {{ error }} </div> <div class="confirmationmessage" *ngif="activatedroute.snapshot.params['keywording'] == 'validateinscription'"><br>un lien de confirmation vous été envoyé sur votre boîte email afin de valider votre compte. merci.</div> <div id="pieddepage"></div>
when running ng serve not catching .
any propositions ??
changing public activatedroute
you need make activatedroute public
. here's checklist when building production aot. ( taken github project https://github.com/asadsahi/aspnetcorespa, though applicable other angular project.)
aot - ahead of time compilation don'ts
- don’t use require statements templates or styles, use styleurls , templateurls, angular2-template-loader plugin change require @ build time.
don’t use default exports.
don’t use form.controls.controlname, use form.get(‘controlname’)
don’t use control.errors?.someerror, use control.haserror(‘someerror’)
don’t use functions in providers, routes or declarations, export function , reference function name inputs, outputs, view or content child(ren), hostbindings, , any field use template or annotate angular should public
keeping activatedroute private
to keep activatedroute private, can this
thedata:any; constructor ( private sessionservice: sessionservice, private router: router, private activatedroute: activatedroute ) { this.activatedroute.params.subscribe( params => { this.thedata= params['keyworking']; //you bind thedata instead of activatedroute } ); }
}
and in template
<div class="confirmationmessage" *ngif="thedata == 'validateinscription'"> <br>un lien de confirmation vous été envoyé sur votre boîte email afin de valider votre compte. merci.</div>
Comments
Post a Comment