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

17th
Nov 2016
Francisco Sales
@franciscofsales
Nov 17 2016 01:34
Hello, does anyone know how to dial a number on ios10?
Valentyn Shybanov
@olostan
Nov 17 2016 01:34
@franciscofsales you can try link with href "tel:222-333-44"
Francisco Sales
@franciscofsales
Nov 17 2016 01:34
i tried href=“tel:xxx”
but no good
at least on the simulator
i also tried window.location = xxx and window.open(‘tel: xx’, ‘_system’)
Francisco Sales
@franciscofsales
Nov 17 2016 01:41
is it because of being on a simulator?
Nick
@ncapito
Nov 17 2016 01:54
Random question for the group.
I had a setup that was working, and i managed to break it. (no suprise).
I basically am inserting into an array on a component and the component is not picking up on the change and re-rendering

am i crazy? If i have:
```export class RecentTasks{
tasks: Task[] = [];
processing: boolean = false;
constructor(
private store: Store,
private storeHelper: StoreHelper,
private tasksService: TasksService
) {

this
  .tasksService
  .loadAll()
  .subscribe(data=>console.log('done'));

}

ngOnInit(){
this.store.changes
.map(data=>data.tasks)
.subscribe(tasks=>{
this.tasks = tasks;
})
}```

`export class RecentTasks{
tasks: Task[] = [];
processing: boolean = false;
constructor(
private store: Store,
private storeHelper: StoreHelper,
private tasksService: TasksService
) {

this
  .tasksService
  .loadAll()
  .subscribe(data=>console.log('done'));

}

ngOnInit(){
this.store.changes
.map(data=>data.tasks)
.subscribe(tasks=>{
this.tasks = tasks;
})
}`

apparently i can't get code to format correctly
Last chance please work (sorry if it doesn't)

export class RecentTasks{
  tasks: Task[] = [];
  processing: boolean = false;
  constructor(
    private store: Store,
    private storeHelper: StoreHelper,
    private tasksService: TasksService
  ) {

    this
      .tasksService
      .loadAll()
      .subscribe(data=>console.log('done'));
  }

  ngOnInit(){
    this.store.changes
      .map(data=>data.tasks)
      .subscribe(tasks=>{
        this.tasks = tasks;
      })
  }
so i can see the this.tasks = tasks getting set but the view doesn't rerender
Nick
@ncapito
Nov 17 2016 01:59
My view is stupid simple:
<ion-item ion-item *ngFor="let t of tasks">
Kyle Roach
@iRoachie
Nov 17 2016 02:19
It looks like you're using redux? With ngrx?
In that case tasks is an observable. Observable<Task[]>
Nick
@ncapito
Nov 17 2016 02:20
I'm using rxjs
Kyle Roach
@iRoachie
Nov 17 2016 02:21
You should be using this.store.select to subscribe to the store
Nick
@ncapito
Nov 17 2016 02:21
?
I mean i see the event firing, and my "controller" setting the new values
i just dont see the view refreshing.
I'm on a stream now if u want to see it https://www.livecoding.tv/ncapito/
It's pretty weird. Bc i swear this setup worked
Nick
@ncapito
Nov 17 2016 02:28
@iRoachie you still there ?
Kyle Roach
@iRoachie
Nov 17 2016 02:28
Here’s my example with it

public collections: Observable<Collection[]>;

constructor(
    public navCtrl: NavController,
    public alertCtrl: AlertController,
    public toastCtrl: ToastController,
    public store: Store<AppState>,
    public collectionActions: CollectionActions) {
    this.collections = this.store.select(state => state.collections);
  }
Nick
@ncapito
Nov 17 2016 02:29
What is store in ur case?
Kyle Roach
@iRoachie
Nov 17 2016 02:29
Well its redux store

import { Collection } from '../models/collection.interface';

export interface AppState {
  collections: Collection[];
}
the is AppState
Nick
@ncapito
Nov 17 2016 02:30
yea my store is a little diff but similar
@Injectable()
export class Store{
    private store = _store;
    public changes = this.store
                    .asObservable()
                    .distinctUntilChanged();
Kyle Roach
@iRoachie
Nov 17 2016 02:31
well yea i just showed the items relavent. I have others as well
why do you need changes ?
Nick
@ncapito
Nov 17 2016 02:31
and the line missing is:
const defaultState: State = JSON.parse(localStorage.getItem('state')) || {
    tasks: [],
    user: {}
};
basically i'm changing data and the view isnt updaiyng
updating*
Kyle Roach
@iRoachie
Nov 17 2016 02:32
I’m taking you’re trying to use localstroage to save your store
Nick
@ncapito
Nov 17 2016 02:32
yea
Kyle Roach
@iRoachie
Nov 17 2016 02:32
there’s a mroe elegant solution, using ngrx-localstorae
Nick
@ncapito
Nov 17 2016 02:32
i
Kyle Roach
@iRoachie
Nov 17 2016 02:32
So st up the reducer as usual then
Nick
@ncapito
Nov 17 2016 02:33
i'm not 100% sure its my problem, bc if i put a breakpoint on my store.changes.subscribe i can see it updating correctly but my view is not reflecting the changes
Feel like i'm missing somthing stupid
Kyle Roach
@iRoachie
Nov 17 2016 02:34
Your example is kind of weird, i havent seen ngrx used like that
Nick
@ncapito
Nov 17 2016 02:35
;) no doubt i'm doing something stupid
Kyle Roach
@iRoachie
Nov 17 2016 02:35
like in your live stream your mutating your array, instead of using actions
Nick
@ncapito
Nov 17 2016 02:35
?
Kyle Roach
@iRoachie
Nov 17 2016 02:37
Why are you doing a push .apply for the ngoninit?
Ngrx store returns an Observable
Nick
@ncapito
Nov 17 2016 02:38
bc i'm paranoid
originally I was doing a this.tasks = tasks
then i was thinking it couldn't detect my reference change
"tasks" is correct and the right state
Kyle Roach
@iRoachie
Nov 17 2016 02:39
tasks: Observable<Task[]>;

constructor(public store: Store<AppState>) {
  this.tasks = this.store.select(state => state.tasks);
}
Nick
@ncapito
Nov 17 2016 02:40
thats the piece i dont get.
how is that diff then the this.store.changes i have ?
Kyle Roach
@iRoachie
Nov 17 2016 02:41
then in template:
<ion-item *ngFor=“let task of (tasks | async)”>
Nick
@ncapito
Nov 17 2016 02:41
my store:
const _store = new BehaviorSubject<State>(defaultState);
woah
the | async ?
Kyle Roach
@iRoachie
Nov 17 2016 02:42
It’s an observable, so it needs the aync pipe
Here’s a tutorial getting you started with ngrx, and observables http://gonehybrid.com/a-beginners-guide-to-using-ngrx-in-an-ionic-2-app-part-1/
Nick
@ncapito
Nov 17 2016 02:43
give me a sec i'm tryin it
Kyle Roach
@iRoachie
Nov 17 2016 02:44
This is all the code you need to display the tasks.
tasks: Observable<Task[]>;

constructor(public store: Store<AppState>) {
  this.tasks = this.store.select(state => state.tasks);
}
Nick
@ncapito
Nov 17 2016 02:45
yea i die a bad death when i try your way
Kyle Roach
@iRoachie
Nov 17 2016 02:46
did you set the tasks property in your class as an operator?
You can just do part of it. You have to do everything
You have the code on a repo or something?
if you upload to github, i could send a PR
Nick
@ncapito
Nov 17 2016 02:47
i do but its private
give me a few im tryin to see how different yours is
do you see how i create my store?
Kyle Roach
@iRoachie
Nov 17 2016 02:50
Okay you dont need ngZone, as rx Observable uses that under the hood
okay your store is good but you dont need a class
import { Collection } from '../models/collection.interface';

export interface AppState {
  collections: Collection[];
}
that’s your entire store there
In your case tasks and user
what does your actions look like
you have an actions file?
Nick
@ncapito
Nov 17 2016 02:54
i dont
and i dont know what an actions file is
Kyle Roach
@iRoachie
Nov 17 2016 02:55
So how are you using redux then??
you need actions to mutate the store
You have a reducer?
for the tasks?
Nick
@ncapito
Nov 17 2016 02:57
One sec. I think in this case i wrote my own store
So, my plan is to just redo all of this
i dont know where i went south. But ill take a look at the link u sent me and start from scratch
Kyle Roach
@iRoachie
Nov 17 2016 03:01
Yea man lemme know if you run into anything
Nick
@ncapito
Nov 17 2016 03:01
Thanks for the help and if ur interested ill let you know if i fix it ;)
Thanks for the help. Sorry for the confusion.
Kyle Roach
@iRoachie
Nov 17 2016 03:02
Yea man np~!
Bastian Bense
@bastibense
Nov 17 2016 06:28
Hey guys, I'm in the process of implementing automatic submission to the AppStore/TestFlight via fastlane. Now I have a question regarding the build process: I'd like to update/build the html/js parts of the app and have them ready in the www/builds folder, so the code is picked up when running gym() on the xcode project (apparently the ionic build process does not run when I do an xcode build/run)
Right now when I run gym(), the xcode project is compiled and archived, but I can't see the linting/tsc/... stuff running before.
Bastian Bense
@bastibense
Nov 17 2016 06:36
nevermind, i think npm run ionic:buildis what I want
Nick
@ncapito
Nov 17 2016 14:30
So @iRoachie i found the line of code that was doing it
Yesterday I changed my URL for my API. If I use the old url I can see the API get hit and the view update. If i use the new one I can see the API get hit but the view doesn't update.
The APIs are returning the same exact data. No console errors
Nick
@ncapito
Nov 17 2016 14:40
Sound familiar to anyone ?
JSponaugle
@JSponaugle
Nov 17 2016 15:40
I am Stuck
I have a ngFor running
But i need to run a command for each ngFor created
Kyle Roach
@iRoachie
Nov 17 2016 15:52
@JSponaugle What command?
Nick
@ncapito
Nov 17 2016 15:59

So I finally fixed my issue. Question for the group. If you have something like:

     <h2>{{user.Company.Name}}!</h2>

And company is null my entire component died with no error message . Is there a way to get Ionic or Angular to log some error ?

Kyle Roach
@iRoachie
Nov 17 2016 16:04
Nah not at the moment. I’m listening to a podcast right now with the google team, and someone brought it up
Andrew Graham-Yooll
@andrewgy8
Nov 17 2016 16:05
<h2 *ngIf="!user.Company">No company here!</h2>
Maybe not the best way of doing it, but it should work
Nick
@ncapito
Nov 17 2016 16:06
I used user?.Company?.Name
Kyle Roach
@iRoachie
Nov 17 2016 16:06
Lol that isn’t logging the error
You’re explicitly checkign
Nick
@ncapito
Nov 17 2016 16:06
but the idea that my component can die if it can't interpolate something scares me
Kyle Roach
@iRoachie
Nov 17 2016 16:06
What you could do though is wrap the h2 in that statement
<h2 *ngIf="user.Company”>{{user.Compant.Name}}</h2>
Nick
@ncapito
Nov 17 2016 16:07
Yea but that starts getting complex and nasty
i already have one at a higher level checking *ngIf='user'
Kyle Roach
@iRoachie
Nov 17 2016 16:08
Well maybe you need to ensure some checks when the data is being created, that it has all the fields
if you can
Nick
@ncapito
Nov 17 2016 16:09
Think of all the bugs that could happen if this doesn't get changed.
Kyle Roach
@iRoachie
Nov 17 2016 16:10
But we as the developer should be responsible for data integrity :D
Nick
@ncapito
Nov 17 2016 16:10
lol
This field is nullable, i wonder if i put a type on it if it will work
JSponaugle
@JSponaugle
Nov 17 2016 17:13
@iRoachie a Custom function
Kyle Roach
@iRoachie
Nov 17 2016 17:29
@JSponaugle Cant you loop over the array in your component and call the function?
bdirito
@bdirito
Nov 17 2016 21:26
whats the best way to package up an app such that it ends up on the [play / apple] stores? Things like (remove unused files) -> concat -> minify -> build -> sign -> upload .. etc. https://ionicframework.com/docs/guide/publishing.html is very ... manual. I can script that up but it seems like these sorts of tools must already exist.