angularjs: a simple registry with change event

This example shows how I used the angular service to build a application registry. I also wanted to listen on registry changes. The service app.service(“Registry”, [“$rootScope”,function($rootScope) { var registryService = { items: [], set: function(key, value) { this.items[key] = value; $rootScope.$emit(“registry.”+key); }, get: function(key) { return this.items[key] || undefined; } }; Read more…

angularjs: summary

General If you uglify angular scripts, remember to use bracket annotation for dependency injection. Modules var myModule = angular.module(“myModule”, [“otherModule”]); Singleton // singleton app.factory(“Service”, function() { var Service = { […] }; return Service; }); Class // function app.factory(“Item”, function() { function Item() { […] }; return Item; }); Configration: Read more…

angularjs: inject html

Angluar dont let you inject HTML content directly. The solution is to create a filter which makrs the html as trusted. app.filter(‘trust’, [‘$sce’, function($sce){ return function(text) { return $sce.trustAsHtml(text); }; }]); In the view the syntax looks like the following: <div ng-bind-html=”item.htmlContent | trust”></div> Source http://stackoverflow.com/questions/19415394/with-ng-bind-html-unsafe-removed-how-do-i-inject-html

first approach to angularjs

Playing around with angularjs, I created an app where you can create and edit items inside a content area. Github: https://github.com/alexwenzel/angular-tryout The facts: an app item, which can be modified by position, color and content an area, where items are displayed an area, where items can be created or edited a Read more…