EMBER— 断言失败:加载路由时出错:类型错误:对象 [对象对象] 没有方法'addArrayObserver'



当我将所有内容作为数组传递时,我得到了所需的结果,即让我的嵌套路由在父模板中显示它的模板。请参阅代码笔简历页面

现在,当我将其转换为夹具数据时,我抛出了一个错误:

Assertion failed: Error while loading route: TypeError: Object [object Object] has no method 'addArrayObserver' 

只有当我resume[1]作为论据传递时,它才会中断。我很困惑为什么这在我的笔中有效,我想知道如何在使用固定装置时修复它

afterModel: function(resume, transition) {
  this.transitionTo('company', resume[1]);
}

完整代码

App = Ember.Application.create({
  LOG_TRANSITIONS: true
});
App.ApplicationAdapter = DS.FixtureAdapter.extend();
// Routes
App.Router.map(function() {
  this.resource('resume', function(){
    this.resource('company', {path: '/:company_id'});
  });
  this.route('contact');
});
App.ResumeRoute = Ember.Route.extend({
  model: function() {
    return this.store.findAll('company');
  }
  ,
  afterModel: function(resume, transition) {
    this.transitionTo('company', resume[1]);
  }
});
App.Company = DS.Model.extend({
  companyName: DS.attr(''),
  jobTitle: DS.attr(''),
  jobDescription: DS.attr(''),
  image: DS.attr(''),
  dates: DS.attr('')
});
// Model Data
App.Company.FIXTURES = [
  {
    id: '1',
    companyName: 'Brandingbrand',
    jobTitle: 'Frontend Web Developer',
    jobDescription: 'Branding Brand powers mobile commerce sites and apps for over 200 of the worlds leading retailers, including American Eagle Outfitters, Crate & Barrel, Ralph Lauren, and Sephora. Our transformative technology is proven, reliable, and limitless. Our work is regularly noted by independent research firms, including Forrester and L2. We are also on CrunchBase. And Facebook. And Twitter. The Branding Brand platform scales to meet client goals and supports all forms of smartphone and tablet output. It requires no IT resources, no systems integration, and no web development. Because our inputs are as limitless as our outputs, we can easily transform any aspect of a desktop site into a unique, optimized experience for smartphones, tablets, or in-store. ',
    image: 'http://b.vimeocdn.com/ps/103/913/1039135_300.jpg',
    dates: 'November 2013 – Current | Pittsburgh Area'
  },
  {
    id: '2',
    companyName: 'PPG Industries',
    jobTitle: 'Frontend Web Designer',
    jobDescription: 'PPG, the worlds leading maker of transportation coatings and a major global supplier of industrial and packaging coatings, flat and fabricated glass, continuous-strand fiber glass, and industrial and specialty chemicals. Our many PPG technologies have been recognized with prestigious R&D 100 Awards and recipients have included. We are also the developers of Transitions® plastic photochromic eyewear lenses that automatically darken when exposed to sunlight. We developed a fiber glass yarn destined to revolutionize the manufacture of circuit boards for computers and other electronic devices Examples of our continuing emphasis on developing high-technology products include.',
    image: 'https://www.xeikon.com/sites/default/files/images/ppg-industries.jpeg',
    dates: 'August 2012 – August 2013 | Pittsburgh Area'
  },
  {
    id: '3',
    companyName: 'Kolano Design',
    jobTitle: 'Graphic Designer',
    jobDescription: 'Kolano Design is a visual marketing firm, based in Pittsburgh, with expertise in graphics, signage and interiors. The graphics team includes media and communications specialists who create strong corporate identities and adapt them to print, advertising, packaging and web. The signage team includes architects and industrial designers who develop signs that build brands and address complex wayfinding challenges. The interiors team includes designers and product inventors who give shape to high profile corporate and residential spaces and consumer products. We hope you enjoy paging through some of our recent work. Give us a call at 412-661-9000. Call us today.',
    image: 'http://pghdesigners.com/images/portfolio/138.jpg',
    dates: 'August 2012 – August 2013 | Pittsburgh Area'
  },
  {
    id: '4',
    companyName: 'Whirl Magazine',
    jobTitle: 'Front End Web Designer',
    jobDescription: 'Founded in 2001, WHIRL is Western Pennsylvanias Premier Lifestyle Magazine. Twelve times per year, WHIRL promotes the people, places, and businesses that help Pittsburgh continue to be "Americas Most Livable City." From fundraisers and galas to after-work happy hours, WHIRL provides a behind-the-scenes look at Pittsburghs vibrant social scene. The success of the magazine is founded on the support of the community and WHIRLs goal to showcase the best of Western Pennsylvania living. Since its foundation, WHIRL Magazine has expanded into a multi-faceted publishing company, including the bi-monthly Edible Allegheny, Pittsburghs main resource for local food and farms.',
    image: 'http://www.themodernmatchmaker.com/wp-content/uploads/2012/08/whirl-magazine-dating-news-articles.jpg',
    dates: 'April 2011 – July 2011 | Pittsburgh Area'
  },
  {
    id: '5',
    companyName: 'Pittsburgh Technical Institute',
    jobTitle: 'Visual Communications Assistant',
    jobDescription: 'Probably the most important advantage for students is the assistance provided by the Career Services department in job search and career assistance. Students can explore employment opportunities on a local, regional and national level through PTI’s network of contacts. All associate degree and many certificate students have the opportunity to experience an industry internship or clinical experience. This further enhances the hands-on experience students enjoy across all programs and builds a strong portfolio. Probably the most important advantage for students is the assistance provided by the Career Services department. This is all without doubt why people come.',
    image: 'http://media.prleap.com/image/17002/full/PTI.png',
    dates: 'March 2010 – July 2011 | Oakdale PA'
  }
 ];

当我控制台.log("公司",简历1)时; — 公司未定义。当我安慰.log("恢复",恢复);和控制台.log("公司",简历);它们都分别返回:

resume 
Class {type: function, store: Class, isLoaded: true, isUpdating: false, constructor: function…}
__ember1388681292354: "ember270"
__ember1388681292354_meta: Meta
_super: undefined
arrangedContent: (...)
content: (...)
get content: function () {
set content: function (value) {
isLoaded: true
isUpdating: false
store: Class
toString: function () { return ret; }
type: App.Company
__proto__: Object
简历不

是一个数组,它是一个集合,所以resume[0]不存在,你应该使用resume.objectAt(0)

最新更新