问题标签 [ember-cli]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ember.js - 如何从 Ember CLI 中的路由访问 Ember 模型
也许对我来说,使用所有代码都位于 app.js 中的常规 Ember 应用程序执行此操作会容易得多。但由于我使用的是 Ember CLI,我无法在我的 Route 中访问我的模型。我仍在尝试学习如何使用 Ember CLI,所以请帮助我。
因为我只想触发 AJAX 调用并让数据在我的 UI 上呈现,所以我下载了 Ember 模型库并将其添加到我的项目中。我认为不需要使用 Ember Data。这是我指的 Ember 模型文档:https ://github.com/ebryn/ember-model#example-usage 。话虽如此,这是 Ember CLI 提出的我的目录结构:
这是对实际项目结构的更简单的表示,我只需要关注这个问题。正如 Ember 模型文档中所建议的那样,我将以下代码添加到我的客户模型 (model\customers.js) 中:
请注意,我必须执行“导出默认值”而不是“App.Customers = Ember.Model.extend...”。这是 Ember CLI 约定。因此,当我尝试访问在客户路线中创建的模型时,我收到错误“加载路线时出错:ReferenceError:未定义应用程序”..
客户路线代码:
我试过 this.model() - 返回 supperWrapper 类型的对象和 this.modelFor() - 返回 null。
请建议如何在其路由中获取我的模型的句柄,以便我可以执行 Ember Model 提供的开箱即用的 CRUD 操作。
谢谢!
ember.js - Ember.js 创建一个没有路由的子控制器
我正在尝试创建一个子控制器来限制要检索的文章数量。这个想法是有这样的东西:
第一个使用 Ember 和 Ember-CLI 的真实项目,所以我仍在消化这些概念。
到目前为止,情况是这样的:
模型/home.js
模型/home-section.js
模型/home-article.js
路线/home.js
模板/home.hbs
模板/home/sections.hbs
我在哪里创建HomeSectionController
. 是controllers/home-section.js
正确的命名结构吗?
非常感谢,
H
更新:
我的疑问是关于没有路由的子控制器,与 ember-cli 没有真正的关系。无论如何,我在这里找到了一个很好的讨论http://discuss.emberjs.com/t/parent-child-controller-relationships-without-using-routes/761/19回答了我之前的一些问题。
ember.js - 在 Ember-CLI 项目中编译 Compass
我正在使用 ember-cli v0.0.23,并试图让 broccoli -compass包与我的项目一起使用,但我遇到了一些问题。
首先,在我的 中Brocfile
,我已经替换了标准的 Ember-CLI“蓝图”版本:
具有以下内容:
但是,当我运行时ember build
,我会收到以下输出:
如果我尝试compass
在终端中运行错误中输出的命令,它会创建文件,只是它位于我的项目根目录的一个目录中(--css-dir
在输出中注意)。
我在调用时尝试了许多选项组合sassDir
,imagesDir
等等compileCompass
,这是我得到的最接近的。
那么关于我可以做些什么来成功获得指南针、broccoli-compass 和 ember-cli 的任何想法?
提前致谢
twitter-bootstrap - 在 Ember.JS ember-cli App 中包含引导库的推荐方法
我正在尝试在我当前的 ember-cli 项目中正确安装 Twitter Bootstrap。我确实用 bower 安装了引导程序:
现在该库已下载到/vendor/bootstrap/dist/(css|js|fonts) 我尝试了这里提到的内容:http: //ember-cli.com/#managing-dependencies 替换路径和 css 文件名,但我得到了有关Brocfile.js文件的错误。我认为与示例相比,brocfile 格式变化太大。
在移动 /app/styles/ 目录中的样式表后,我还尝试使用/app/styles/app.css文件 @import :
但它没有用。这些文件是可见的真正的开发服务器:http://localhost:4200/assets/bootstrap.css
有人可以在这里扔我一根骨头吗?
谢谢
编辑 :
brocfile.js
ember.js - 在 Ember 数据中过滤子记录
我无法过滤 ArrayController 中对象的子记录。
我的模型的结构是这样的:
商店有很多产品,产品属于一个商店。我想根据Ember.TextField过滤每个父母的子记录。如果我仅使用正则表达式根据父记录所拥有的属性过滤父记录,则过滤有效。
编辑
我尝试在这里使用承诺(来源:使用 Ember.js 过滤子记录(hasMany 关联)),但似乎从未访问过此 productSearchResults 属性。我没有从这里得到任何日志输出。在模板中,我正在遍历filteredProducts,但那里什么也没有。如果它有任何相关性,我正在使用 Ember 1.5.0 和 Ember Data 1.0.0-beta.7+canary.b45e23ba 。
ember.js - Including dependencies with ember-cli
I am trying out ember-cli to get an ember project going, however I have previously relied on rails and the asset pipeline to compile all my js and (s)css for previous projects.
I admit a weak understanding of js build tools, so apologies if the question is basic: How can I see what dependencies are being compiled/included in the build? Specifically, I want to include both zurb-foundation and ember-leaflet in my project. I am not sure if they are there (at least the leaflet map is not showing up in the project --- using a basic example that worked with both rails and rail-eak).
The files (ember-leaflet, etc) are in the vendor directory of the project and were placed there thru bower install (I assume?); do I have to manually include them in the root bower.json file (currently they are not); is the order in bower.json important?
Thanks in advance.
DJ
ember.js - 西兰花服务不会重新加载 ember 应用程序
我正在为当前的 ember 项目使用ember-cli,我使用启动服务器,broccoli serve
但是 livereload 不起作用,每次进行更改时我都需要刷新页面。将 livereload 与 ember-cli 和 broccoli 一起使用的正确方法是什么?
ember.js - 如何在 ember-cli 中导入命名 amd 及其导出
我正在尝试将ic-modal导入 ember-cli 项目,但由于某种原因,我不断收到此错误:
Uncaught Error: <ic-test@view:toplevel::ember278> Handlebars error: Could not find property 'ic-modal-trigger' on object (generated application controller).
我有以下导入语句:
app.import('vendor/ic-styled/main.js');
app.import('vendor/ic-modal/dist/named-amd/main.js', {
'ic-modal': [
'ModalComponent',
'ModalFormComponent',
'ModalTriggerComponent',
'ModalTitleComponent',
'modalCss'
]
});
对此有任何帮助吗?
ember.js - API 代理服务器
我正在使用 ember-cli。需要调用远程服务器,我无法控制 API,并且 API 上没有设置 CORS。
我正在努力设置代理服务器。理想情况下,我喜欢使用 ember-cli 内置的东西。我见过代理选项“ember serve --proxy”,但我不知道如何使用它。
我基本上想做:
当我这样做时,我得到:
也在研究 nginx,但我不知道如何在本地设置它或如何让它与 ember-cli 服务器一起工作。
任何帮助深表感谢!
谢谢
javascript - emberjs ember cli 玉模板无法编译?
我正在使用ember-cli来设置我的新 emberjs 应用程序。虽然我能够成功安装翡翠,但它似乎没有呈现添加到 /app 目录的 .jade 模板?
想法?当前包.json:
文件夹中有一个相当小的模板,用以下代码/app
命名:error.jade
当我运行ember serve
或ember build
它永远不会被编译。其他一切都是 ember cli 中的标准设置。我跑去npm install --save broccoli-jade
安装。这是我为此问题embercli-emberjs-test设置的示例 repo 。理想情况下,我想编译把手和玉模板。
想法?github问题