Showing posts with label AngualrJS for .Net developers in 24 hours. Show all posts
Showing posts with label AngualrJS for .Net developers in 24 hours. Show all posts

Wednesday, February 10, 2016

one time binding - Angular JS 1.3 removed from the $Watch list page 56 AngualrJS for .Net developers in 24 hours, $digest cycle, "dirty list"

<!-- View showing one-time binding.-->
<div ng-controller="Order as vm">
    <input type="text" ng-model="vm.orderTotal" />
    <p>{{ ::vm.orderTotal }}</p>
</div>

Prototypal inheritance - page 53 AngualrJS for .Net developers in 24 hours,

Prototypal inheritance is a concept that gives a lot of JavaScript developers problems, especially coming from a classical inheritance background. It’s a vitally important concept, though. To read more about prototypal inheritance, check out the Mozilla Developer Network’s JavaScript Guide. It’s full of great information on JavaScript.

<!-- View without ControllerAs syntax that has nested scopes.-->
<div ng-controller="Order">
    <input type="text" ng-model="orderTotal" />
    <div ng-if="showDetails">
        <input type="text" ng-model="orderTotal" />
    </div>
</div>

You can avoid all of that mess by using ControllerAs syntax:
<!-- View with nested scopes, but with ControllerAs.-->
<div ng-controller="Order as vm">
    <input type="text" ng-model="vm.orderTotal" />
    <div ng-if="showDetails">
        <input type="text" ng-model="vm.orderTotal" />
    </div>
</div>

Now the two models explicitly share the same scope of the controller’s alias, vm, and we’ve tamed the scope craziness.