I have a problem with my AngularJS Application, I try to call a function in my Controller but the parameter when I console.log(id);
, id is an array...
[ ]
instead of {{ }}
because i'm working with TWIGAngular Template (html source)
<div class="ext-[f.ext]" ng-repeat="f in files">
<input type="checkbox" ng-click="select([f.id],'file')">
<div>[f.name]</div>
</div>
Rendered by Angular
<div class="ext-html" ng-repeat="f in files">
<input type="checkbox" ng-click="select(27,'file')">
<div ng-binding">index.html</div>
</div>
My JS function
$scope.select = function (id ,type) {
console.log(id); // Array
console.log(type); // String (as expected)
}
console Output :
[28] app.js:74
file app.js:75
The problem is that I have this which works...
<div class="folder row" ng-repeat="f in folders" ng-click="getFolder([f.id])">
<div class="col-md-12">[f.name]</div>
</div>
You're specifying an array as the parameter.
<input type="checkbox" ng-click="select([f.id],'file')">
Should be
<input type="checkbox" ng-click="select(f.id,'file')">
You create arrays in javascript using the square brackets.
var array = [ 1, 2, 3, 4];
So you created an array with a single value in which was your id.