如何在同一页面上同时使用angularJS和knockoutJS

时间:2016-04-14 07:42:14

标签: javascript angularjs knockout.js mosaico

我的应用程序是使用AngularJS开发的,但现在我将实现'Mosaico电子邮件模板编辑器'(使用KnockoutJS开发)..所以如何在同一页面上同时使用Angular和Knockout ..任何人都可以解释示例代码.. ?? tanx提前

我的示例代码:

<script  type="text/javascript" src="js/core/controller/knockout.js"></script>
<script src="dist/vendor/jquery.min.js"></script>
<script type="text/javascript" src="js/core/controller/controller.js"></script>

    <div data-bind="foreach: templates">
          <div class="template template-xx" style="" data-bind="attr: { class: 'template template-'+name }">
            <div class="description" style="padding-bottom:5px"><b data-bind="text: name">xx</b>: <span data-bind="text: desc">xx</span></div>
            <a href="#" data-bind="click: $root.newEdit.bind(undefined, name), attr: { href: 'editor.html#templates/'+name+'/template-'+name+'.html' }">
              <img src="/images/full.png" width="100%" alt="xx" data-bind="attr: { src: 'templates/'+name+'/edres/_full.png' }">
            </a>
          </div>
        </div>


 *[and JS file below - controller.js][1]*

    var viewModel = 
          {
               templates: 
                [
                    {
                      name: 'versafix-1', desc: 'The versatile template'
                    },
                    {
                      name: 'tedc15', desc: 'The TEDC15 template'
                    }        
                ]

          };

    document.addEventListener('DOMContentLoaded',function(){
            ko.applyBindings(viewModel);
          });

前两张图片 - 我期待但我现在得到了正确的一面...我认为淘汰赛绑定在我的页面中无法正常工作:

First two image - what i expect but i get now right side one...i think knockout binding not working properly in my page

0 个答案:

没有答案