The biggest advantage of using WinJS to build Windows Store and Windows Phone apps is the ability to reuse all we know and love about the web including the awesome open source libraries and frameworks. WinJS adds a layer of security on certain functions that manipulate the DOM. You can read more about it here. You usually find out about this by hitting the error: Unable to add dynamic content.

error.png

In AngularJS, the developer community has communicated a number of ways to mitigate this.

  • Changing the source code to wrap the offending lines with the execUnsafeLocalFunction. Yuck! This is the worst approach since it makes upgrading to the latest version more complex than it should be.
  • Replacing Angular's jqLite with jQuery 2.x, which already addresses this issue. This seems like overkill to me. jqLite is often all I need when using Angular.
  • Using the ngCsp directive on the html element: <html ng-csp>. I had some success with this approach for a time, but at one point it stopped working and rather than troubleshooting what I did to break it, I moved on to the approach I recommend in this post. Which is ...

jscompat.png

The Microsoft OpenTech team has released the winstore-jscompat script on GitHub and this has worked flawlessly for me. You simply place it as the very first script in your pages and forget about it.

<!DOCTYPE html>
<html data-ng-app="app">
<head>
    <meta charset="utf-8" />
    <!-- Mitigate dynamic content security issue -->
    <!-- See https://github.com/MSOpenTech/winstore-jscompat for more information -->
    <script src="/vendor/winstore-jscompat.js"></script>
    ...

They report a minor performance hit, but I haven't noticed it.

I'm finally getting around to learning AngularJS and am absolutely loving it. Having spent a lot of time with Knockout (and a little time looking at Backbone), I really like how Angular apps are structured. It resonates with me. I've also been meaning to take BreezeJS for a spin and I really like it so far. It really simplifies rich data interactions like complex queries and caching. I'll post more specifics about these tools as I get more familiar with them.

js.png

As a learning tool, I'm using John Papa's fantastic Pluralsight course Building Apps with Angular and Breeze, wherein he builds out a fully functioning single page app called CodeCamper over the course of 10+ hours. My favourite aspect of his course is how he doesn't skimp on proper code structure. Sure it takes more time, but the refactorings and rationale behind his structure makes this an excellent real-world learning tool. I highly recommend it - and its 5-star rating with over 400 viewers would indicate I'm not the only one.

Thanks John. Really nice work!

6 0
Don Smith made a comment

The Intel Galileo

I have a deep interest in the trend towards an Internet of Things (IoT) and one aspect of that interest is in the actual devices, sensors, circuits, and code that runs on them. Over the past year I've been playing with the Arduino Uno, the Beaglebone Black (BBB), and the Raspberry Pi (RPi). Asking me which one I like the most is like asking which is my favourite between Windows Phone, iPhone, and Android. Fact is, I like them all, just for different reasons. And, today my shiny new Intel Galileo arrived.

galileo.png

Admittedly, I got this one more for work than for play, but so far I have been WAY more impressed with this board than I thought I would be. So I thought in this post I would mention a few of the features I am finding noteworthy. If you're looking to setup your new Galileo, I used the excellent SparkFun walkthrough, but it looks to be just a slightly easier-to-read version of the Getting Started Guide from Intel (PDF).

Easy code deployment & add-on shields

My favourite feature of the Arduino is how easy it is to deploy code to the board. Whether going straight to the board with USB or through an FTDI breakout like I use with my LilyPad, it's the click of a button in the development environment. And there are so many great libraries and code samples from Adafruit, SparkFun, and out in the wild, you can make these boards do just about anything when combined with the multitude of add-on shields.

The Galileo doesn't use the same exact development environment as the Arduino, but they both originate from the Processing development environment and will be immediately familiar with anyone who has done Arduino development. It's the same language (C), you assign pins the same way, and almost all Arduino code just works. The Galileo also has the same header pinouts as the Arduino Uno so, while I haven't tried it just yet, my NFC shield (along with the associated library) should work fine with with the Galileo. This is noteworthy!

Access to Linux & horsepower

What I really like about the BBB and the RPi is the ability to run Linux on the metal. I'm a big fan of node.js and Python and being able to run mini web APIs and package managers on such a small form factor (despite the security threats) just makes me smile inside.

The Galileo has a tiny build of Linux as its firmware/bootloader baked onto its 8Mb SPI flash memory that can be updated through the dev environment (yes, that's very cool). But if you want to run what they call "Big Linux" you just need a micro SD card between 1 and 32 Gb (not 4Gb like the other boards) - I'm using a 2Gb one. This was easy to set up and node.js and python are already installed in the image provided. Smiling on the inside ...

Oh, and if you don't have a micro SD card handy and still need a command line fix, no problem. Just upload a simple script and you'll be able to use a serial terminal to log into "Little Linux". This was also pretty easy.

Onboard ethernet & storage

While ethernet and micro SD storage are built-in on the BBB and RPi, to get it on my Arduino, I had to get this shield. Sure it works, but it increases the cost and the size of the form factor. Not so with the Galileo as both are built-in. Unfortunately, the Galileo doesn't have built-in wifi. The other boards don't have 802.11 built-in either, but they have plenty of extra normal-size USB ports and setting up wifi dongles was easy. The Galileo only has one micro USB port ... but it also has a mini PCI Express (mPCIe) bus on the bottom ... which can take one of these (that's right, wifi AND Bluetooth 4). Mine should arrive early next week :)

Wrap up

So it's early days, but it's looking like this board is giving me most of my favourite features of my existing boards and more. It would be nice if there were some good enclosures available, but I'll probably just 3D print one for the time being. I'm mostly interested in using it with Bluetooth 4 and the XBee modules that are on the way so I can explore some connectivity options. More on that later. Oh, and I also have a Touch Board on the way to explore conductive ink. More on that too.

Fun fun fun! Let me know if you have any questions.

Intelligent portfolios for developers and designers.

We build factual up-to-date portfolios from sites you use to showcase your skills, expertise, traits, code, designs, education, and more.


CREATE YOUR FREE PORTFOLIO

RSS feeds

Filter results

Tag

Coder

Full search

Newest opportunities

Newest posts