How to dynamically pass parameter to ionic tabs templateUrl?

I have tried:

templateUrl: function($stateParams) {
   return 'templates/' + $stateParams.url ;
}

The above returns this error:

ionic.bundle.js:18526 GET file:///android_asset/www/templates/undefined net::ERR_FILE_NOT_FOUND

And from this link (Dynamic template from url) tried:

        templateUrl: ['$stateParams',function($stateParams) {
          console.log("Menu :"+$stateParams.url) ;
          return 'templates/'+ $stateParams.url ;
        }],

When I click the sub link on the tab, I get this error:
ionic.bundle.js:18526 GET file:///android_asset/www/$stateParams,function%20($stateParams)%20%7B%20%2…templates/'%20+$stateParams.url%20;%20%20%20%20%20%20%20%20%20%20%20%20%7D

Neither works. I know I am close but can’t see what I am doing wrong. Please help, driving me nuts over here.

When I click on the TAB Menu sub ion-item, its supposed to take me to a unique ‘account.html’ or ‘contact.html’ page - but instead it takes me back to the /tab/main because of the $urlRouterProvider.otherwise(‘/tab/main’) ;