0

Right now I have this component, it is a search function component:

App Search Result

Here is the code for it:

<StackLayout>
    <StackLayout class="form">
        <StackLayout class="input-field">
            <TextField hint="Tournament Name" [(ngModel)]="query"></TextField>
        </StackLayout>
        <Button text="Search" (tap)="onSubmit()"></Button>
    </StackLayout>
    <Scrollview height="80%">
        <StackLayout>
            <GridLayout *ngFor="let result of results" (tap)="onTap(result.tournament_id)" columns="*, *" rows="auto, auto, auto, auto, auto, auto" borderWidth="1px">
                <Label  [text]="result.name" row="0" col="0" colspan="2" ></Label>
                <Label  [text]="result.organization" row="1" col="0" colspan="2" ></Label>
                <Label  [text]="result.date" row="2" col="0" ></Label>
                <Label  [text]="result.time" row="2" col="1" ></Label>
                <Label  [text]="result.game" row="3" col="0" colspan="2" ></Label>
                <Label  [text]="result.style" row="4" col="0" colspan="2" ></Label>
                <Label  [text]="result.location" row="5" col="0" colspan="2" textWrap="true"></Label>
            </GridLayout>
        </StackLayout>
    </Scrollview>
</StackLayout>

Clicking on one of the tournament descriptions should bring up a tournament profile page like so:

Tournament Page on Web

Right now I have an onTap wired to the boxes as such here:

  onTap(id){
    console.log("tapped", id);
    this.routerExtensions.navigate(["/tournaments","profile", id]).then(nav => {
              console.log(nav); // true if navigation is successful
              }, err => {
              console.log(err) // when there's an error
              });

  }

When I click a box it prints out:

tapped {id} //first click
true
tapped {id} //subsequent clicks
null

How do I create Angular web routerlink like behavior in a nativescript app where clicking on an object brings up another component?

1 Answer 1

1

You should use nsRouterLink as discussed in the Angular Navigation docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.