small medium large xlarge

2012-08-16-102302_pragsmall
23 Feb 2017, 11:25
Michael Pope (10 posts)

I just moved CustomerSearchComponent to a separate file as per PG 127 and I got this error when running ‘rake’

1) angular test Our Angular Test App is Working Failure/Error: expect(page).to have_content(“Name”) expected to find text “Name” in “Signed in successfully. Angular Test” # ./spec/features/angular_test_app_spec.rb:22:in `block (2 levels) in <top (required)>’

If I start foreman and go to /angular_test the name field is not displaying anymore.

Here is the bottom of my application.js file where the CustomerSearchComponent used to be;

var CustomerSearchComponent = require(“./CustomerSearchComponent”);

// Top Level SearchComponent var CustomerSearchAppModule = ng.core.NgModule({ imports: [ ng.platformBrowser.BrowserModule, ng.forms.FormsModule, ng.http.HttpModule ], declarations: [ CustomerSearchComponent ], bootstrap: [ CustomerSearchComponent ] }).Class({ constructor: function() {} });

// Add event listener for customer search component document.addEventListener(‘DOMContentLoaded’, function() {

if (document.getElementById(“shine-customer-search”)) { // Tell Angular that we are running within a browser ng.platformBrowserDynamic. platformBrowserDynamic(). bootstrapModule(CustomerSearchAppModule); } });

Dmfcb_pragsmall
23 Feb 2017, 13:02
David Copeland (475 posts)

Can you open up your JavaScript console and see if it shows any errors when you go there in your browser? Often this is the only place you’ll find out what’s broken (and if you are anything like me it’s probably a missing comma or other syntax error JavaScript doesn’t bother to tell you about :)

2012-08-16-102302_pragsmall
26 Feb 2017, 00:44
Michael Pope (10 posts)

After a full nights rest I have found the problem. The problem was I moved too much into the customer search component specifically I moved the following var AngularTestAppModule = ng.core.NgModule({…}) and document.addEventListener(‘DOMContentLoaded’, function() {…}) for the AngularTest this explains why.

I’m really enjoying the book, thanks David.

Dmfcb_pragsmall
26 Feb 2017, 15:35
David Copeland (475 posts)

Cool, glad you figured it out. The JS stuff is very powerful, but it’s easy to break and tends to fail in weird (to me) ways. Almost feels like learning to program all over again :

You must be logged in to comment