Newbie Routing Question: Ionic Route Parameter?


#1

This works as expected:

In index.html
      {{#ionItem path="lists" iconLeft=true iconRight=true}}
 
In router.js:
    this.route('lists');

I’d like to pass a parameter with a categoryName to my template file. After much googling, I’m trying this:

In index.html:
        {{#ionItem path="lists/categoryName" iconLeft=true iconRight=true}}

In router.js:
    this.route('lists', {path: '/lists/category'});

This results in a console error:

debug.js:41 Exception in template helper: TypeError: Cannot read property ‘path’ of undefined

How can I correct this?

Thanks very much in advance to all for any info.


#2

I found a way to do it.

In index.html:

{{#ionItem path="lists" hash="categoryName" iconLeft=true iconRight=true}}

Note- there is a data parameter, i.e. data=“categoryName”, but so far I have found no way to access it from the template helper.

In router.js:

this.route('lists', function() {
    this.subscribe('database');
    this.render('lists', {
    data: {
        data: this.params.hash
    }
    })
});

In the template helper:

aHelperFunction: function () {
   var parameter = this.data;
   return ;
}

If there is a better/more preferred way, please let me know.