使用ember.js 2.0在ember cli应用程序中进行基础

时间:2015-07-20 12:15:42

标签: javascript ember.js zurb-foundation ember-cli

我正在使用ember-cli处理ember应用程序。

ember版本为"2.0.0-beta.2"

我正在将基础5集成到应用程序中,为基础安装了bower包,并将其包含在 ember-cli-build.js 文件中

app.import('bower_components/foundation/js/foundation/foundation.js');
app.import('bower_components/foundation/js/foundation/foundation.offcanvas.js');

现在我想将基础初始化为

Ember.$(document).foundation({
  offcanvas: { close_on_click: true }
});

但在ember-2中,他们已完全删除了视图,我应该在哪里初始化它?

有什么想法吗?

感谢。

1 个答案:

答案 0 :(得分:4)

终于能够解决它了...感谢" Taras Mankovski"

以下是解决方案https://github.com/embersherpa/ama/issues/8

application.hbs

    var paymentsMethod = {'credit card':false,'cash':false,'check':false};

    angular.forEach(paymentsMethod,function(value,key){
        if(key === docDetails.p_method){
            paymentsMethod[key] = true
        }
    });

    $scope.paymentsMethod = paymentsMethod;

    $scope.p_change = function(method){
        paymentsMethod = {'credit card':false,'cash':false,'check':false};
        angular.forEach(paymentsMethod, function(value,key){
            if(key === method){
                if(docDetails.p_method===method){
                    paymentsMethod[key]=true;
                }
                paymentsMethod[key] =  paymentsMethod[key] === true ? false : true;
            }
        });
        $scope.paymentsMethod = paymentsMethod;
    };

部件/应用-canvas.js

{{#app-canvas}}
  <h2>Welcome to Ember.js</h2>
  {{outlet}}
{{/app-canvas}}