AngularJS | handle routing before they load

Issue I wish to create a simple authentication check for my routes by external service. I define the access requirements on the route object: $routeProvider .when(‘/’, { templateUrl: ‘src/app/views/index.html’, controller: ‘indexCtrl’, authenticated: true }) .when(‘/login’, { templateUrl: ‘src/app/views/login.html’, controller: ‘loginCtrl’,

Continue reading

Accessing formgroup in custom validator

Issue I’m trying to add custom validator to my component.ts customvalidatorFile: import { FormGroup, ValidationErrors } from ‘@angular/forms’; export class ProfileCustomValidators { static validateTime(fg: FormGroup): ValidationErrors { const staffForm = fg.get(‘staffForm’) const fromTime = staffForm.get(‘fromTime’).value; const toTime = staffForm.get(‘toTime’).value; if(fromTime

Continue reading

Angular Custom Async Validator Not Showing Error

Issue My async validator is not working when I actually make an async call (but works when I mock it with Observable.of(result). The html looks like this: <div class=”form-group”> <label for=”emailAddress” class=”control-label”>Email</label> <input type=”email” id=”emailAddress” class=”form-control” [(ngModel)]=”parent.EmailAddress” name=”emailAddress” [ngModelOptions]=”{updateOn: ‘blur’}”

Continue reading

Validators angular

Issue I am trying to force Validators.required for the password field in the same modal. If it is an update, it will not catch Validators.required otherwise it will get an error. Help me! Thanks you! userForm() { const special =

Continue reading

Reactive forms angular show error for pattern in angular

Issue I have reactive form like this this.form = this.formBuilder.group({ email: [”, [ Validators.required, Validators.maxLength(120), Validators.pattern(‘^[^\\s@]+@[^\\s@]+\\.[^\\s@]{1,}$’) ]], }); Now I need to display error for different error, like this <div class="invalid-feedback" *ngIf="form.controls.email.errors.pattern">THIS EMAIL NOT VALID</div> But I got error Cannot

Continue reading

Mat error is not displaying error for custom validators but template is displaying error

Issue app.component.html <div class="col-sm-3"> <mat-form-field class="col-sm-3" appearance="outline" class="example-full-width input-small-size d-block"> <mat-label>Personal Phone 1 </mat-label> <input matInput formControlName="phonePersonal01" type="number"> <mat-error *ngIf="personalform.errors?.invalidPhoneMatch"> Enter different numbers. </mat-error> <!– This error is not displaying –> </mat-form-field>{{personalform.errors|json}} <!– Output is : { "invalidPhoneMatch": true }–>

Continue reading

Custom Validator on Angular logic gets implemented successfully but does not show the error message on my web page UI /HTML

Issue so I was doing a custom validator on my Angular form which works in the following way: excerpt from my component.ts file: creteRoute(): FormGroup { return this.fb.group({ ‘departure_airport_id’: [”, Validators.required], ‘departure_airport_code’: [”, Validators.required], ‘route_freequency’: [”, [Validators.required, Validators.pattern("^[0-9]*$")]], ‘arrival_airport_id’: [”,

Continue reading

Angular: Cyclic Dependency

Issue Why is currentdate in this.currentdate.getTime() coming back as undefined? newlisting = this.formBuilder.group({ availabledate: new FormGroup({ xyz: new FormControl() },[this.mainservice.getcurrenttime.bind(this)]) }) @Injectable({providedIn: ‘root’}) export class MainService { constructor(){} currentdate: Date = new Date(); getcurrenttime(control: FormGroup){ console.log(this.currentdate.getTime()) <~~ Generates Error!!! if(condition){

Continue reading

python 2.7 and opencv code gives cvtcolor error

Issue faceCascade = cv2.CascadeClassifier(‘haarcascade_frontalface_default.xml’) video_capture = cv2.VideoCapture(0) while True: ret, frame = video_capture.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale( frame, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.cv.CV_HAAR_SCALE_IMAGE ) # Draw a rectangle around the faces for (x, y, w, h) in

Continue reading

c++ using-keyword in python

Issue In c++ you generally can do this: using LCN = longNamespace::sub::subsub::LongClassName so you don’t have to write a long classname everytime. Is there a similar keyword or workaround in python for static classmethods. class MyPythonClassWithLongName: @staticmethod def foo(): pass

Continue reading

Is this the right usage of using?

Issue I am not sure how to use using statement correct. I try like this: [HttpDelete("{ClubId}", Name = "DeleteOpenings_Club")] public async Task<IActionResult> DeleteClub_IsOpening([FromRoute] string ClubId) { using (_db_ClubIsOpen) { var result = _db_ClubIsOpen.ClubIsOpen_TBL.Where(x => x.FK_Club == ClubId); foreach (var item

Continue reading

Is this the right usage of using?

Issue I am not sure how to use using statement correct. I try like this: [HttpDelete("{ClubId}", Name = "DeleteOpenings_Club")] public async Task<IActionResult> DeleteClub_IsOpening([FromRoute] string ClubId) { using (_db_ClubIsOpen) { var result = _db_ClubIsOpen.ClubIsOpen_TBL.Where(x => x.FK_Club == ClubId); foreach (var item

Continue reading

Is this the right usage of using?

Issue I am not sure how to use using statement correct. I try like this: [HttpDelete("{ClubId}", Name = "DeleteOpenings_Club")] public async Task<IActionResult> DeleteClub_IsOpening([FromRoute] string ClubId) { using (_db_ClubIsOpen) { var result = _db_ClubIsOpen.ClubIsOpen_TBL.Where(x => x.FK_Club == ClubId); foreach (var item

Continue reading