简体   繁体   English

显示带有角度js数据绑定形式的引导箱

[英]Showing the bootbox with the angular js data binded form

I started using Angular JS just 2 weeks back and is very much amazed with the data binding feature of it. 我仅在两周前开始使用Angular JS,它的数据绑定功能让我非常惊讶。

Also I am very fond of using bootboxjs to show the messages and all the info to the user. 我也非常喜欢使用bootboxjs向用户显示消息和所有信息。

I am just thinking can we show the data binded form of Angular JS in bootbox through custom dialog. 我只是想我们可以通过自定义对话框在启动箱中显示Angular JS的数据绑定形式。

I tried but I am not getting the content infact the dialog box is showing the the template as it is and not with the data. 我试过了,但实际上我没有得到内容,对话框将按原样显示模板,而不显示数据。

How can we show the data in bootbox UI with the data already binded with it. 我们如何在Bootbox UI中显示已绑定数据的数据。

You must use the $compile. 您必须使用$ compile。

http://code.angularjs.org/1.2.13/docs/guide/compiler http://code.angularjs.org/1.2.13/docs/guide/compiler

As example: 例如:

            var tplCrop = '<div><img ng-src="{{file.src}}"/></div>';
            var template = angular.element(tplCrop);
            var linkFn = $compile(template);
            var html= linkFn($scope);

            bootbox.dialog({
                message: html,
                title: "My title",
                buttons: {
                    ok: {
                        label: "Ok",
                        className: "btn-success",
                        callback: function () {
                        }
                    },
                    close: {
                        label: "Close",
                        className: "btn-danger",
                        callback: function () {
                        }
                    }
                }
            });

I suggest you this pretty good example Plunker how to pass data to Dialog. 我建议您使用这个非常好的示例Plunker如何将数据传递给Dialog。

However its not bootbox (that uses jQuery). 但是,它不是bootbox(使用jQuery)。 The demo shows dialog based only on bootstrap and angualrJS. 该演示显示仅基于bootstrap和angualrJS的对话框。

Hope it will help 希望对你有帮助

Now there is a very nice module, to handle that with separate template file! 现在有一个非常好的模块,可以使用单独的模板文件来处理它! https://github.com/eriktufvesson/ngbootbox https://github.com/eriktufvesson/ngbootbox

very nice! 非常好!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM