Jak*_*zyk 5 angularjs angularjs-components
我正在研究Angular 1.5中的应用程序.我坚持使用基于组件的体系结构(https://docs.angularjs.org/guide/component)和那里描述的输入/输出流程.
到目前为止,它工作正常,但现在我需要打开一个子组件作为对话窗口,我卡住了.
从主组件开始渲染组件树时,该体系结构很好.但我不知道如何获得其中一个孩子并将其显示为对话框,仍然使用推荐的输入/输出流程.
你知道任何模式/库吗?
小智 3
图书馆将是有角的材料:
https://material.angularjs.org/latest/demo/dialog
该模式必须是这样的:
// my-dialog.js
'use es6'
export default locals => ({
locals, // will be bound to the controller instance!
template:
`
<p>Something: <span>{{$ctrl.foo}}</span></p>
<md-button ng-click="$ctrl.onSave()">Save</md-button>
<md-button ng-click="$ctrl.cancel()">Cancel</md-button>
` ,
bindToController: true,
controllerAs: '$ctrl',
controller: function($mdDialog, myService) {
// this.foo = ..will be provided in locals as an input parameter..
// this.onSave = () { ..will be provided as output parameter.. }
this.cancel = () => {
$mdDialog.cancel()
}
},
clickOutsideToClose: true
})
Run Code Online (Sandbox Code Playgroud)
您可以像这样从父组件调用:
// main-component.js
'use es6'
import myDialog from './my-dialog'
..
$mdDialog.show(myDialog({
foo: 'bar',
onSave: () => { .. }
}))
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
2516 次 |
| 最近记录: |