在您首先编写的新ember应用程序中:
var App = Ember.Application.create({
test: 'foo',
...
});
Run Code Online (Sandbox Code Playgroud)
在您首先编写的新ember-cli应用程序中:
var App = Ember.Application.extend({
test: 'foo',
...
});
Run Code Online (Sandbox Code Playgroud)
为什么?
(在第二种情况下,我无法从控制器读取全局属性(App.test).!?)
我似乎无法获得从单元测试触发的模型钩子和动作.
任何使用此ember-cli环境的样本/博客都将是一个很大的帮助!
我发现这个链接 什么样的单元测试解决方案在Ember.js的路线?
但是route.model()将错误抛出为:未定义transition.
import { test, moduleFor } from 'ember-qunit';
moduleFor('route:sample', 'SampleRoute', {
// Specify the other units that are required for this test.
});
test("beforeModel hook works", function(){
var route = this.subject();
Ember.run(function(){
route.set("model", "Sample data");
})
console.log("Model set. Was beforeModel hook called?");
});
Run Code Online (Sandbox Code Playgroud)
样本路线
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function (transition) {
console.log("Inside before-model hook");
},
afterModel: function() {
console.log("In after-model hook");
}
});
Run Code Online (Sandbox Code Playgroud) 我正在研究一个我在S3中部署的ember-cli应用程序.我真的希望能够使用这种"无服务器"方法,因为它配置非常简单,而且非常实惠.
我的网址有问题.如果我点击http://my-bucket.s3-website-us-east-1.amazonaws.com/就可以了.但是如果我尝试直接加载除应用程序根目录之外的页面,例如http://my-bucket.s3-website-us-east-1.amazonaws.com/elephants/5,那么它会给出403 ,因为S3中没有这样的资源.(我可以通过应用程序很好地导航到这些页面,我可以在我的机器上以开发模式直接命中它们,因此ember应用程序工作正常.)
寻找解决方案,我找到了添加到我的路径的建议#!.这似乎更好,因为它没有返回403,但当我点击http://my-bucket.s3-website-us-east-1.amazonaws.com/#!/elephants/5时,它只是重定向到http://my-bucket.s3-website-us-east-1.amazonaws.com,丢失路径中包含的任何特定信息.
我有什么选择?有没有办法使用S3并有工作的URL?我需要服务器吗?还是有另一种方法让我望而却步?
我需要一些帮助..
刚刚将我的ember-cli更新为0.1.9版本,唯一的问题就是这个警告:
警告:忽略bower_components/route-recognitionizer/dist/route-recognizer.js的输入源图,因为ENOENT,没有这样的文件或目录'/Users/Zaca/Eyenetra/portal/tmp/tree_merger-tmp_dest_dir-kOIywY0K.tmp/bower_components/route -recognizer/DIST/route-recognizer.js.map"
这是我在brocfile.js上对这个插件的调用:
//brocfile.js
(...)
app.import('bower_components/moment/moment.js');
app.import({development: 'bower_components/route-recognizer/dist/route-recognizer.js'});
app.import({development: 'bower_components/FakeXMLHttpRequest/fake_xml_http_request.js'});
app.import({development: 'bower_components/pretender/pretender.js'});
module.exports = app.toTree();
Run Code Online (Sandbox Code Playgroud)
当我为测试和本地服务器构建项目时会发生这种情况.
有任何想法吗?
谢谢您的帮助!O /
我正在使用ember-cli的pod结构来按资源分组JS和模板,这是一个巨大的进步.资源相关逻辑的最后遗迹是CSS(SCSS)文件,它们已经沿着类似于行的行分解,但仍然存在app/styles.
我的想法是将CSS文件移动到名称下的每个pod中style.css.我的问题是如何指示SASS(via @import)指令和/或Broccoli在pod中查找SCSS文件(可能是几层深度)并将它们编译成appname .css.
我正在获得一个POST https://heroku_client_path.herokuapp.com/login 405 (Not Allowed)带有Rails api的Ember.js应用程序(两者都在heroku上)
处理登录或注册时.我觉得请求URL应该是heroku服务器路径/登录,因为我设置了我的ADAPTER_URLheroku配置var,而不是上面显示的heroku客户端URL.
我相信我已正确设置CORS.
我正在使用Ember-CLI.我用手滚动认证它不是Simple-Auth.
environment.js:
module.exports = function(environment) {
var ENV = {
modulePrefix: 'client-rantly',
environment: environment,
baseURL: '/',
adapterURL: process.env.ADAPTER_URL,
locationType: 'auto',
EmberENV: {
FEATURES: {
}
},
};
if (environment === 'development') {
}
if (environment === 'production') {
}
return ENV;
};
Run Code Online (Sandbox Code Playgroud)
适配器/ application.js中:
import DS from 'ember-data';
import ENV from '../config/environment';
export default DS.ActiveModelAdapter.extend({
host: ENV.adapterURL || ENV.ADAPTER_URL,
headers: function () {
return {
'auth_token': localStorage.getItem('authToken')
}; …Run Code Online (Sandbox Code Playgroud) 我通过Bower成功导入了一个jQuery插件,用于Ember-cli插件中的一个组件.但是,这只是因为我在插件和使用应用程序中定义了对此插件的Bower依赖性.
这似乎我做错了.为什么消费应用程序必须声明对应该与插件一起提供的资源的依赖?
事情的关键似乎是app建设时的背景.如果我import在addon的index.js文件中使用以下语句,我可以省略使用应用程序中的Bower依赖项:
app.import('node_modules/my-ember-cli-addon/bower_components/jquery.stickyHooters/dist/jquery.stickyHooters.min.js');
Run Code Online (Sandbox Code Playgroud)
...但是当我将插件构建为独立应用程序时,这会中断.在这种情况下,此路径是必需的:
app.import('bower_components/jquery.stickyHooters/dist/jquery.stickyHooters.min.js');
Run Code Online (Sandbox Code Playgroud)
这是如何工作的?
app上下文index.js我正在构建一个相对直接的comment-list组件.我想传递可评论的模型(比如说a Post)并让组件负责创建,编辑和删除注释.现在我传递了各种各样的动作,而且非常脆弱.
如何在组件集成测试中创建Ember Data模型的真实实例?
我的直接想法是导入模型然后.create({})它,但错误use this.store.createRecord() instead
/* jshint expr:true */
import { assert } from 'chai';
import { describeComponent, it } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
import Post from 'ownersup-client/post/model';
describeComponent( 'comment-list', 'Integration: CommentListComponent', {
integration: true
},
function() {
it('renders all of the comments', function() {
const model = Post.create({ title: 'title' });
model.get('comments').createRecord({ body: 'One Comment' })
this.render(hbs`{{comment-list model=model}}`);
assert.lengthOf(this.$('.comment-list-item'), 1);
});
}
);
Run Code Online (Sandbox Code Playgroud)
有人有什么想法?
我有两个嵌套这样的路线.
router.js
this.route('profile', function() {
this.route('edit');
});
Run Code Online (Sandbox Code Playgroud)
像这样的这些路线的几个导航栏链接..
navbar.hbs
{{#link-to 'profile' tagName="li"}}<a href>View Profile</a>{{/link-to}}
{{#link-to 'profile.edit' tagName="li"}}<a href>Edit Profile</a>{{/link-to}}
Run Code Online (Sandbox Code Playgroud)
该link-to助手添加active类到li这里的标签.因此,当我在profile路线时,第一个链接有active类,当我在profile.edit路线时,两个链接都有active类.(显然是因为profile.edit访问时两条路线都被激活了.)
如何在子路由中避免父路由链接获取active课程?
基本上我不希望第一个链接(to profile)active在profile.edit路线上有课.
我将ember-cli升级到版本2.4.3
npm install -g ember-cli
Run Code Online (Sandbox Code Playgroud)
我可以在列出的依赖项中看到 - ember-cli@2.4.3,但是当我检查时:
(master *)$ ember -v
version: 2.4.2
node: 5.6.0
os: darwin x64
Run Code Online (Sandbox Code Playgroud)
ember cli版仍然是2.4.2
怎么了 ?
ember-cli ×10
ember.js ×10
javascript ×2
amazon-s3 ×1
broccolijs ×1
cors ×1
ember-data ×1
heroku ×1
sass ×1
unit-testing ×1
url ×1