These are chat archives for angular/angular-2-ionic-2

12th
May 2017
Damon Casale
@damoncasale
May 12 2017 00:05
Got another question. I'm attempting to check the valid state of a FormControl object.
Apparently FormGroup.controls['controlName'].valid is a function, not a boolean.
So...how do I use that? I want to check to see if the control itself is valid or not.
Damon Casale
@damoncasale
May 12 2017 00:14
I checked the documentation, and the docs say it's a boolean. The docs are lying.
UncertaintyP
@UncertaintyP
May 12 2017 00:40
Hmm get valid(): boolean|null { return this.control ? this.control.valid : null; }
so it should be gettable
nah its this but sill get valid(): boolean { return this._status === VALID; } a boolean
Damon Casale
@damoncasale
May 12 2017 00:44
Yeah, for some reason the form CONTROL says it's valid but the form GROUP is invalid?? wtf.
This is a form with one required field. I'm clicking on the submit button and getting really weird behavior.
UncertaintyP
@UncertaintyP
May 12 2017 00:47
If there is only one that is valid, this is indeed strange
Damon Casale
@damoncasale
May 12 2017 00:47
There's only one field, the control says it's valid...but it's not.
UncertaintyP
@UncertaintyP
May 12 2017 00:48
Oh you mean you typed in an invalid value and it still validates to true?
Damon Casale
@damoncasale
May 12 2017 00:49
I typed in NO value, and the field is required.
UncertaintyP
@UncertaintyP
May 12 2017 00:53
theoretically this should work
Damon Casale
@damoncasale
May 12 2017 00:53
Yeah...so why isn't it working. -_-
What's worse, on the page where I have this one field, I commented out the submit part. And the form STILL submits. wtf...
Ah, there was a JS error that was causing the form submit to go through.
Damon Casale
@damoncasale
May 12 2017 01:04
Ok, so FormControl.valid is true, FormControl.invalid is false, and FormControl.errors is null...
This doesn't make any sense at all.
I guess Ionic is bugged?
Or Angular 4.0.2...
UncertaintyP
@UncertaintyP
May 12 2017 01:05
why
Damon Casale
@damoncasale
May 12 2017 01:05
Because the control ISN'T valid.
And FormGroup.valid is false.
UncertaintyP
@UncertaintyP
May 12 2017 01:05
but its consistent :D
Damon Casale
@damoncasale
May 12 2017 01:05
Heh.
UncertaintyP
@UncertaintyP
May 12 2017 01:06
Oh the group is invalid but the only object is valid o.O
Damon Casale
@damoncasale
May 12 2017 01:06
Yeah.
Mind-fucking...
Damon Casale
@damoncasale
May 12 2017 01:12
THERE we go. Figured it out.
For the validator, I had to do: ['', Validators.compose([...])]
I only had the Validators.compose in there.
Harald Wiesinger
@s3ppo
May 12 2017 12:57
is there a good location to update a online status on my api every 10 seconds if the user is active?
Damon Casale
@damoncasale
May 12 2017 20:12
Anyone experienced some images not appearing when running on a device, but all appearing when running ionic serve?
I'm using media queries to identify which image should display, but for the device it's not loading them. I'm inspecting w/ Safari and it's getting a 404.
Odutayo Ayooluwa
@dtytomi
May 12 2017 22:31

Hello geeks, hackers, coders and programmers. I need you help on how to use InAppBrowser with the current version of IONIC. Here is a snippet of my code

login(url): Promise <any> {

return new Promise((resolve, reject) => {
  // body...
  this.plt.ready().then(() => {

    let browser =  this.iab.create(url, '_blank', 'location=no,EnableViewPortScale=yes,closebuttoncaption=Done');

    browser.on('loadstart').subscribe((event: any) => {

      console.log("I got in here to subscribe");

      this.hasToken = event.url.indexOf('?oauth_token=');
      this.hasUserId = event.url.indexOf('&userId=');     

      if (this.hasUserId > -1 && this.hasToken > -1) {
        browser.close();

        this.token = event.url.match('oauth_token=(.*)&userId')[1];
        this.userId = event.url.match('&userId=(.*)')[1];
        this.storage.ready().then(() => {

          // set a key/value
          this.storage.set(this.HAS_LOGGED_IN, true);
          this.storage.set('token', this.token);
          this.storage.set('token-date', JSON.stringify(new Date()));
          this.storage.set('userId', this.userId);

        });

        resolve(event.url);

      }  
      else {
        reject("Problem authenticating with social media account");
      }
    });
  });

});

}

Am having problem of being able to get event. Thanks
@damoncasale I would advice you use Chrome. And can you post a code snippet or you folder structure of where the image is saved.
Damon Casale
@damoncasale
May 12 2017 23:05
@dtytomi I'm using Chrome.
In my scss, I have this:
/ Extra high density (640), xxhdpi /
@media screen and (-webkit-device-pixel-ratio: 3) {
.tabProfileImage {
background: url('../assets/images/navbar/AccountNonSelected@3X.png') no-repeat center center;
background-size: 23%;
}}
I also have a substitute image w/o the media query.
The substitute image seems to get found just fine (I've tested that by unchecking the background style given by the above media query, and seeing the image pop up on my device), but the @3X version doesn't.
Gives me a 404.
Is Ionic's tree-shaking buggy or something?
Btw, for your event not being detected, loadstart is likely firing before this.plt.ready().
Damon Casale
@damoncasale
May 12 2017 23:21
Guessing ionic-app-scripts' build process is too smart for its own good.
It's probably excluding the other image files because it doesn't realize they'll be used, because it doesn't properly parse media queries.