Difference between MEAN.js and MEAN.io

They’re essentially the same… They both use swig for templating, they both use karma and mocha for tests, passport integration, nodemon, etc. Why so similar? Mean.js is a fork of Mean.io and both initiatives were started by the same guy… Mean.io is now under the umbrella of the company Linnovate and looks like the guy … Read more

No ‘Access-Control-Allow-Origin’ – Node / Apache Port Issue

Try adding the following middleware to your NodeJS/Express app (I have added some comments for your convenience): // Add headers before the routes are defined app.use(function (req, res, next) { // Website you wish to allow to connect res.setHeader(‘Access-Control-Allow-Origin’, ‘http://localhost:8888’); // Request methods you wish to allow res.setHeader(‘Access-Control-Allow-Methods’, ‘GET, POST, OPTIONS, PUT, PATCH, DELETE’); // … Read more

AngularJs $http.post() does not send data

I had the same problem using asp.net MVC and found the solution here There is much confusion among newcomers to AngularJS as to why the $http service shorthand functions ($http.post(), etc.) don’t appear to be swappable with the jQuery equivalents (jQuery.post(), etc.) The difference is in how jQuery and AngularJS serialize and transmit the data. … Read more

Where to put model data and behaviour? [tl; dr; Use Services]

You should use services if you want something usable by multiple controllers. Here’s a simple contrived example: myApp.factory(‘ListService’, function() { var ListService = {}; var list = []; ListService.getItem = function(index) { return list[index]; } ListService.addItem = function(item) { list.push(item); } ListService.removeItem = function(item) { list.splice(list.indexOf(item), 1) } ListService.size = function() { return list.length; } … Read more

AngularJS app.run() documentation?

Here’s the calling order: app.config() app.run() directive’s compile functions (if they are found in the dom) app.controller() directive’s link functions (again, if found) Here’s a simple demo where you can watch each one executing (and experiment if you’d like). From Angular’s module docs: Run blocks – get executed after the injector is created and are … Read more

How to preventDefault on anchor tags?

According to the docs for ngHref you should be able to leave off the href or do href=””. <input ng-model=”value” /><br /> <a id=”link-1″ href ng-click=”value = 1″>link 1</a> (link, don’t reload)<br /> <a id=”link-2″ href=”” ng-click=”value = 2″>link 2</a> (link, don’t reload)<br /> <a id=”link-4″ href=”” name=”xx” ng-click=”value = 4″>anchor</a> (link, don’t reload)<br /> … Read more

Global variables in AngularJS

You’ve got basically 2 options for “global” variables: use a $rootScope http://docs.angularjs.org/api/ng.$rootScope use a service http://docs.angularjs.org/guide/services $rootScope is a parent of all scopes so values exposed there will be visible in all templates and controllers. Using the $rootScope is very easy as you can simply inject it into any controller and change values in this … Read more

$rootScope.$broadcast vs. $scope.$emit

tl;dr (this tl;dr is from @sp00m’s answer below) $emit dispatches an event upwards … $broadcast dispatches an event downwards Detailed explanation $rootScope.$emit only lets other $rootScope listeners catch it. This is good when you don’t want every $scope to get it. Mostly a high level communication. Think of it as adults talking to each other … Read more

What does MVW stand for?

It stands indeed for whatever, as in whatever works for you per Igor Minar from 2012 (emphasis mine): MVC vs MVVM vs MVP. What a controversial topic that many developers can spend hours and hours debating and arguing about. For several years +AngularJS was closer to MVC (or rather one of its client-side variants), but … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)