I have this AngularJS app.
(我有这个AngularJS应用程序。)
Everything works just fine.(一切正常。)
Now I need to show different pop-ups when specific conditions become true, and I was wondering what would be the best way to proceed.
(现在我需要在特定条件成立时显示不同的弹出窗口,我想知道什么是最好的方法。)
Currently I'm evaluating two options, but I'm absolutely open to other options.
(目前我正在评估两个选项,但我绝对愿意接受其他选择。)
Option 1(选项1)
I could create the new HTML element for the pop-up, and append to the DOM directly from the controller.
(我可以为弹出窗口创建新的HTML元素,并直接从控制器附加到DOM。)
This will break the MVC design pattern.
(这将打破MVC设计模式。)
I'm not happy with this solution.(我对这个解决方案不满意。)
Option 2(选项2)
I could always insert the code for all the pop-ups in the static HTML file.
(我总是可以在静态HTML文件中插入所有弹出窗口的代码。)
Then, using ngShow
, I can hide / show only the correct pop-up.(然后,使用ngShow
,我可以隐藏/只显示正确的弹出窗口。)
This option is not really scalable.
(此选项不是真正可伸缩的。)
So I'm pretty sure there has to be a better way to achieve what I want.
(所以我很确定必须有更好的方法来实现我想要的。)
ask by Bruno translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…