Tuesday, 31 May 2016

Post 51: MVG (Münchener Verkehrsgesellschaft) U-Bahn as a CSS art with one DIV element

This train is called MVG U-Bahn. It's operating in Munich. I drew it with CSS and one HTML element.




Monday, 16 May 2016

Post 50: Solutions to "Introduction to Algorithms 3rd edition" by CLRS

Starting with today I'll post my solution to the book "Introduction to Algorithms 3rd Edition" by CLRS on this blog:

http://solution-clrs.blogspot.de/

Every post that I make there, contains a solution for one excercise. If you think I made a mistake feel free to comment on the corresponding post.

Sunday, 8 May 2016

Post 48: Source for finding angularJS libraries

If you want to download angularJS library on your local machine, e.g. so you can also work offline, then you got these options:

- Go to this page:

https://cdnjs.com/libraries/angular.js/

Then select the angularJS version and after that find the library.

- Or go to https://docs.angularjs.org/api

Then search for the module.

Saturday, 7 May 2016

Post 47: AngularJS directives

You can define directives in AngularJS as
- Element ("E"):
<my-directive></my-directive>
notice that we don't use self closing tags, i.e. <my-directive/> because some browsers can't handle self-closing tags

Use this for UI widgets.

- Attribute ("A"):
<h3 my-directive></h3>

Use this for mixin behaviours, e.g. tooltip

- Class name ("C")

<h3 class="my-directive"></h3>

- Comment ("M")
  <!-- directive: my-directive -->

Post 46: displaying a html module with ng-include

If you are writing AngularJS and want to use ng-include in order to display a html module within your page, for example this:

my-html-file.html:
<html ng-app="myAngularJSapp">
...
            <h3 ng-include="'product-title.html'"></h3>
...
</html>

my-module.html:
            <h1>{{product.name}}</h1>
            <h2>{{product.price | currency}}</h2>


Then you may notice this error message if you are loading your page with your file server:

angular.min.js:103 XMLHttpRequest cannot load file:///home/my-html-file.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.(anonymous function) @ angular.min.js:103
The reason why this happens is, that ng-include makes a XMLHttpRequest. If you're opening your page via your file server this XMLHttpRequest will not work because your localhost is not able to handle HTTP request.

Solution:
- run the code on a webserver
- Run a simple server with python -m SimpleHTTPServer
- install a simple server on your machine, e.g. https://github.com/devpaul/grunt-devserver 

Tweet