Vote count:
0
TL;DR directive interpolates array as string..
http://ift.tt/RFBqER
Here is code:
index.html
<!DOCTYPE html>
<html data-ng-app="foo">
<head>
<script src="http://ift.tt/1qFKioj"></script>
<script src="app.js"></script>
</head>
<body data-ng-controller="FooCtrl">
<ul data-foo="{{foo.bar}}">
<li data-ng-repeat="bar in foo.bar">
{{bar}}
</li>
</ul>
</body>
</html>
app.js
!(function(ng) {
'use strict';
FooCtrl.$inject = ['$scope'];
function FooCtrl($scope) {
$scope.foo = {
bar: [
'foo',
'bar'
]
};
}
function FooDirective() {
return {
restrict: 'A',
scope: {
model: '@foo'
},
link: function($scope) {
var watcher = function(model) {
console.log(model, typeof model);
};
$scope.$watch('model', watcher, true);
}
};
}
ng.module('foo', [])
.controller('FooCtrl', FooCtrl)
.directive('foo', FooDirective);
})(window.angular);
Why do I have "typeof model" string instead of array?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire