简体   繁体   中英

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

When I pass everything in as just an array I get the desired result which is having my nested route display it's template inside the parent template. See codepen resume page

Now when I convert this to fixture data I get an error thrown:

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

It only breaks whenever I pass resume[1] as an argument. I'm confused why this works in my pen and I would like to know how to fix it when I use fixtures

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

Full Code

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'
  }
 ];

When I console.log('company', resume 1 ); — company is undefined. When I console.log('resume', resume); and console.log('company', resume); they both return respectively:

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不是数组,而是集合,因此resume[0]不存在,应使用resume.objectAt(0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM