Href 在 ion-option-button 中不起作用?
Href doesn’t work in ion-option-button?
大家好,
在一个离子项目中,我制作了一个离子列表离子项目和这些离子选项按钮:
<ion-item ng-repeat="(id,place) in places" >
<h2>{{place.name}}</h2>
<ion-option-button class="button-positive" href="#/tab/place/{{id}}">
edit
</ion-option-button>
</ion-item>
但是 href="..." 不工作
感谢帮助
Href 属性应该与锚标记一起使用。您可以尝试使用锚标记包装 ion-option-button 或使用 onClick 等事件使用 javascript 代码进行导航。
在angularJS中,href的正确使用方法是
<a ng-href="#/tab/place/{{id}}"></a>
希望对您有所帮助:)
试试这个
<h2>{{place.name}}</h2>
<ion-option-button class="button-positive">
<a href="#/tab/place/{{id}}">
edit
</a>
</ion-option-button>
我解决了问题:
模板:
<ion-option-button class="button-positive" ng-click="goTo('edit-place',{'placeId':id})">
控制器:
$scope.goTo=function (state,params) {
$state.go(state,params);
}
由于您使用的是 ui-router,因此您无需创建 goTo 函数。只需使用 ui-sref 加载您的动态状态。另外,我会尽量不要在状态名称 (editPlace) 中使用“-”。
<ion-option-button class="button-positive" ui-sref="edit-place({placeId:id})">edit</ion-option-button>
大家好, 在一个离子项目中,我制作了一个离子列表离子项目和这些离子选项按钮:
<ion-item ng-repeat="(id,place) in places" >
<h2>{{place.name}}</h2>
<ion-option-button class="button-positive" href="#/tab/place/{{id}}">
edit
</ion-option-button>
</ion-item>
但是 href="..." 不工作
感谢帮助
Href 属性应该与锚标记一起使用。您可以尝试使用锚标记包装 ion-option-button 或使用 onClick 等事件使用 javascript 代码进行导航。
在angularJS中,href的正确使用方法是
<a ng-href="#/tab/place/{{id}}"></a>
希望对您有所帮助:)
试试这个
<h2>{{place.name}}</h2>
<ion-option-button class="button-positive">
<a href="#/tab/place/{{id}}">
edit
</a>
</ion-option-button>
我解决了问题:
模板:
<ion-option-button class="button-positive" ng-click="goTo('edit-place',{'placeId':id})">
控制器:
$scope.goTo=function (state,params) {
$state.go(state,params);
}
由于您使用的是 ui-router,因此您无需创建 goTo 函数。只需使用 ui-sref 加载您的动态状态。另外,我会尽量不要在状态名称 (editPlace) 中使用“-”。
<ion-option-button class="button-positive" ui-sref="edit-place({placeId:id})">edit</ion-option-button>