AngularJS 1.5。
如何使用ui-sref指令傳遞組件內的參數?angularjs 1.5使用ui-sref將參數傳遞給組件使用ui路由器和組件,使用ui-sref
了header.html:
<a ui-sref="dashboard({contentType: 'company'})">Company</a>
app.js:
.state('dashboard', {
url: "/dashboard",
component: "dashboard",
resolve: {
}
})
儀表板component.js:
angular.module('myModule').component('dashboard', {
templateUrl: '/views/admin/dashboard.html',
controller: DashboardController,
binding: {
contentType: '<' // This is not working...
}
});
dashboard.html:(希望看到的contentType在這裏 - 但是沒有...)
contentType: {{$ctrl.contentType}}
謝謝,不知道關於「PARAMS」但儘管如此,這並沒有奏效爲了我。 1.在儀表板的綁定中,我還需要「contentType:'<'」嗎? 2.儀表板組件被放置在ui-view指令中 - 我需要指定它嗎(類似於
? – chenop@chenop這是一個[示例plunker](https://plnkr.co/edit/CgHJ7HSeFOu6dyGjv0QW?p=preview)演示它是如何與'ui-router'和'components'一起工作的,如果這有助於你解決問題,那麼很好,否則你可以用我的代碼,叉子和共享URL來修改它 – tanmay
欣賞你的幫助意願。闖入者證明了這個問題: https://plnkr.co/edit/ebxaP8xcCXeIaLiiZ61K?p=preview – chenop