[英]How do i pass data through ui-view (UI-Router)?
我正在使用多個命名視圖來嵌套它們。 我想做的是從div中將調用模板的一些數據傳遞到模板本身中。
像這樣
<div ui-view="inputtext" data-value="0"></div>
<div ui-view="inputtext" data-value="1"></div>
<div ui-view="inputtext" data-value="2"></div>
我想要相同的模板,但是將不同的數據傳遞給它。
我該如何實現?
這就是我的狀態
.state('project', {
url: "/project/:projectId",
views: {
'project' : {
templateUrl: "templates/project.html"
},
'group@project' : {
templateUrl: "templates/group.html"
},
'task-1@project' : {
templateUrl: "templates/task-1.html"
},
'inputtext@project' : {
templateUrl: "templates/modules/inputtext.html"
}
}
在“項目”中,我有多個“組”,在“組”中,我有多個“任務”,在“任務”中,我想顯示多個“輸入文本”,但每個值都不同
function whatyouwannaget()
{
var scriptUrl = "url";
$.ajax({
url: scriptUrl,
type: 'get',
dataType: 'html',
async: false,
success: function(data) {
result = data;
}
});
return result;
您可以使用ui路由器的stateparams
讓你的HTML成為
<a ui-sref=".detail({id: show.id})">{{show.name}}</a>
和您的路由配置是這樣的。
.state('app.subscribers.detail', {
url: 'detail/:id',
views: {
'detail@app.shows': {
templateUrl: 'templates/partials/show-detail.html',
controller: 'showCtrl'
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.