Categoryjavascript

Javascript related posts.

Recent deployment issue with Sailsjs and no assets being loaded. 

If you find it that when you deploy your sails app and no assets are being loaded. It’s because grunt is not being run when running sails lift.

Here is what I found was causing the problem.  Sails looks for this file .sailsrc when you run the app, it will override settings. In this case when I started the app grunt was not run.

After removing the grunt property the .sailsrc file looked like below.

 

Access and Update Model Outside Angular

In a recent project I had a form within an Iframe that needed to talk to the parent frame via postMessage. The parent frame was an angular application and I had to show and hide some content. I was able to access the scope outside angular and update via the angular.element() method (This is using version 1.4.2).

 

Using Pathmodify a Browserify plugin with Gulp

To better understand what we are going to solve in this post take a look at what Pathmodify does.

gulpfile.js

Notice lines 8-11 which is where the pathmodify plugin is used. On lines 9-10 is where we will alias a directory. We will take line 10 as an example from here on. The method .dir in pathmodify.mod.dir() takes two arguments. The first is the name of the alias in this case it’s “ng_services”, and this can be anything you want. The second argument is the absolute system path where your in this case angular services reside.

app.js 

Now, in our app.js file we can use these new alias within our require() methods.  Take a look at all the require methods and notice how the alias are used.  So, now instated of using something along the lines of ../../../../../ you can just use the alias.

© 2017 Aldo Lugo

Theme by Anders NorenUp ↑