javascript - 在 Angular Meteor 中使用 Blaze 模板

标签 javascript angularjs meteor angular-meteor

我正在尝试使用 useraccounts:bootstrap在 Angular Meteor 应用程序中使用 urigo:angular-blaze-template包以使用 useraccounts:bootstrap 提供的 blaze 模板 {{> atForm}}

问题:我在网页上遇到错误:meteorTemplate:没有名为“todoList”的模板。有什么想法吗?

useraccounts.html

<template name="todoList">
    {{> atForm}}
</template>

<blaze-template name="todoList"></blaze-template>

routes.js

angular.module('myApp').config(function($urlRouterProvider, $stateProvider, $locationProvider) {
    $locationProvider.html5Mode(true)

    $stateProvider
        .state('useraccounts', {
            url: '/useraccounts',
            templateUrl: 'client/useraccounts/views/useraccounts.html',
        })

    $urlRouterProvider.otherwise('/foo')
})
<小时/>

按照 Jos Jarink 的建议,缺少模板的错误消失了!但 {{> atForm }} 不包含任何内容,仅包含以下嵌套在 uiView div 内部的代码。

blaze-html-templates 软件包已被删除,添加回来似乎没有任何区别。

<div class="container">
    <!-- uiView:  -->
    <div ui-view="" class="ng-scope">
        <blaze-template name="atForm" class="ng-scope">
            <div class="at-form ng-scope">
            </div>
        </blaze-template>
    </div>
</div>
<小时/>

更新

Github 存储库: https://github.com/nyxynyx/useraccounts-angular

取消注释 .meteor/packages 中的 blaze-html-templates 会出现错误

Errors prevented startup: While determining active plugins: 
error: conflict: two packages included in the app (angular-templates and templating) are both trying to handle *.html 

最佳答案

将 Blaze 模板放入另一个文件中,就像放置 Angular html 的位置一样。即输入 <template>在另一个文件中,<blaze-template>保留在您的 Angular html 文件中。

useraccounts.html

<blaze-template name="todoList"></blaze-template>

useraccounts_blaze.html

<template name="todoList">
    {{> atForm}}
</template>

另请参阅:https://stackoverflow.com/a/34073593/5543045

更新并检查 atForm 是否存在:

如果您想检查 blaze-template 是否找到了 atForm 或任何其他模板,您可以添加一个简单的模板助手来尝试查找模板名称。 像这样的东西:

Template.todoList.helpers({
    isThatTemplateHere: function (name) {
        var tmpl = Template[name];
        if (tmpl)
            return name + ' was found';
        else
            return name + ' was not found';
    }
});

在你的模板中:

<template name="todoList">
    {{isThatTemplateHere "atForm"}}
    {{> atForm}}
</template>

关于javascript - 在 Angular Meteor 中使用 Blaze 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34341389/

相关文章:

javascript - 是否有一个函数可以使用 JavaScript 在 HTML 元素中的另一个单词前面添加一个单词,例如 p 标签

javascript - ANGULARJS - 仅在提交时验证

javascript - MeteorJS 和 alethes :pages

javascript - 显示 Meteor 中的所有用户

javascript - 实现HighCharts与server.R之间的通信

javascript - 使用点运算符调用 javascript 函数

javascript - 向组合框添加默认值

angularjs - 在 Angular-ui Bootstrap 轮播之外获取事件幻灯片索引

angularjs - 关键帧不适用于 Firefox 或 Safari 中的 AngularJS 动态添加的类

Meteor ORM 多态和 Mongo 文档