I have two templates, Father.html and Detail.html. I would click on a link in the Father template and access correctly to the Detail template, but i see the previous template with overlapped the components of the next. (I tried with ui-sref) Here is the code:
(Myapp.js)
.state(‘father’, {
url: “/father”,
templateUrl: “templates/father.html”,
controller: “CtrlFather”
})
.state(‘detail’, {
url: “father/detail”,
templateUrl: “templates/detail.html”,
controller: “CtrlDetail”
});
(Father.html)
<ion-view>
...
<a ui-sref="detail">
...
</ion-view>
In the Detail template i haven’t used the ion-view due to an error that cause the block of the application.
Any ideas?
ghprod
December 7, 2014, 2:51pm
2
Could you setup codepen for your code?
Here you are:
index.html
<ion-view>
<ion-header-bar class="bar-positive">
<button class="button icon ion-arrow-left-c"></button>
<h1 class="title">Father</h1>
</ion-header-bar>
<div style="margin-top:100px">
<tr ng-if="$first" class="row">
<div ng-if="$index % 2==0"></tr><tr class="row">nuova riga</div>
<div class="col col-50" ng-class="{'center':$last}">
<span><a style="display:block;width:100px;height:100px;border-radius:50px;font-size:20px;color:#fff;line-height:100px;text-align:center;background:#000" href="detail">vai</a>: {{father.tipo}}</span>
This file has been truncated. show original
script.js
angular.module('starter', [
'ionic',
'ngRoute',
'starter.father',
'starter.detail',
'restangular'
])
$stateProvider.state('father', {
url: "/father",
templateUrl: "templates/father.html",
This file has been truncated. show original
yyebmo.markdown
yyebmo
------
A [Pen](http://codepen.io/anon/pen/yyebmo) by [Captain Anonymous](http://codepen.io/anon) on [CodePen](http://codepen.io/).
[License](http://codepen.io/anon/pen/yyebmo/license).
This issue was solved! I deleted various < ion-header-bar> and substitute it with the general < ion-nav-bar> and < ion-nav-back-button> , after that I added an abstract state for menu in myapp.js and used $stateParams for passing parameters from the parent to the son controller:
MYAPP.JS
.state(‘menu’,{
url:"/menu",
templateUrl: “templates/menu.html”,
controller: “CtrlMenu”,
abstract=true,
})
.state(‘menu.father’, {
url: “/father”,
views: {
‘menuV’: {
templateUrl: “templates/father.html”,
controller: “CtrlFather”
}
}
})
.state(‘menu.detail’, {
url: “/detail/:id”,
views: {
‘menuV’: {
templateUrl: “templates/detail.html”,
controller: “CtrlDetail”
}
}
});
SON.JS
angular.module(…).controller(…, function(…){
$currentId=$stateParams.id ;
$scope.getElWithID = function(id){
…
}
$scope.getElWithID($currentId);
FATHER.HTML
…
{{parent.name}}
MENU.HTML
…
< ion-nav-view name=“menuV”>< /ion-nav-view>