Piotr Kowalski
Cyfrowy Polsat, Warsaw
JavaScript Ninja. Mac lover. Open source fan.
Organizer WarsawJS
"Kto chce szuka sposobu, kto nie chce szuka powodu."
Object
itselfMethod
's parametersObject
's direct component objectsObject
, in the scope of method
Reference: https://en.wikipedia.org/wiki/Law_of_Demeter
$scope.title = 'Function';
// Mozilla Firefox support Arrow Function natively.
setTimeout(() => {
$scope.title = 'Arrow Function?';
}, 1000);
// Controller
$scope.dataStructure = { foo: 'bar' };
// View
<span ng-bind="dataStructure"></span>
{{ dataStructure }}
{{ dataStructure | json }}
// View (compiled)
[object Object]
{"foo":"bar"}
{ "foo": "bar" }
mod.controller('HelperController', function ($scope) {
$scope.helper = 1;
});
mod.controller('DependencyController', function ($scope, $controller) {
var $newScope = $scope.$new();
$controller('HelperController', {
$scope: $newScope
});
console.log($newScope.helper); // 1
});
<!-- interpolation -->
<span ng-cloak>{{ title }}</span>
<!-- directive ng-bind -->
<span ng-bind="title"></span>
<ng-switch on="foo">
<span ng-switch-when="bar">Bar</span>
<span ng-switch-when="baz">Baz</span>
<span ng-switch-when="abc">Abc</span>
<span ng-switch-default>...</span>
</ng-switch>
<body ng-init="cut = false;">
<div ng-cut="cut = true">
Lorem ipsum...
</div>
Cut? {{ cut }}
</body>