Open radoszabelian opened 9 years ago
I have the same problem
Same here
Same here
Odd enough, what I found is that the data will be bound in the controller if you click the <th>
checkbox, therefore selecting all rows, it will then update the model.
Selecting individual rows won't update the modalData.selected
variable to the controller even though it correctly updates in the view (for instance {{ modalData.selected }}
anywhere in the view would render the array correctly, whereas in the controller it wouldn't.).
Taking the example pen as a base for tests, add the following code:
$scope.$watch('selected', function() {
console.log($scope.selected);
});
And add the following to the markup (just anywhere you'd like):
{{ selected }}
You'd notice that when individual rows are selected, the view updates correctly but nothing gets written to the JS console. When you select all rows at once through the <th>
checkbox, however, both view and $watch are triggered, outputting correctly to the view and the console.
@daniel-nagy Is this unexpected behavior or am I missing something? (a promise, or whatsoever?)
Same issue here, but strangely enough only in production. In my local MAMP environment it works just fine.
Did anyone ever figure this out? We have an app in production where we've hacked something together for the moment but this is a really weird bug and one that we can't seem to diagnose.
@mcblum I was getting this error because of some dependencies in bower that would not update correctly due to the dependencies included in this package.
Here is a portion of my bower.json
"dependencies": {
"angular": "*",
"angular-animate": "*",
"angular-aria": "*",
"angular-material": "*",
"angular-route": "*",
"angular-ui-router": "*",
"components-font-awesome": "*",
"angular-material-icons": "*",
"angular-messages": "*",
"angular-material-data-table": "~0.8.14"
},
"resolutions": {
"angular": "1.4.7"
}
I would then have to run
bower install --force-latest
The data table then worked for me.
Also, I used this
instead of $scope
. Not sure how much of a difference that made.
Hm. I just did that on the server and nothing. Already using controllerAs so I'm with you there. The strange thing is, it works in my dev environment but not in production. Thanks for helping with this @JoshBargar
@mcblum What are your your dev dependencies?
Here's the bower.json
"dependencies": {
"bootstrap": "~3.3.5",
"angular": "~1.4.7",
"angular-ui-router": "ui-router#~0.2.15",
"angular-sanitize": "~1.4.3",
"trumbowyg-ng": "~0.0.3",
"angular-material": "*",
"growl": "~1.3.1",
"angular-material-data-table": "~0.8.14",
"angular-ui-sortable": "~0.13.4",
"ng-file-upload": "~9.1.1",
"aws-sdk": "aws-sdk-js#~2.2.10",
"ng-lodash": "~0.3.0",
"ngstorage": "~0.3.9",
"imgix.js": "~2.0.0",
"es5-shim": "~4.3.1",
"es6-shim": "~0.33.12"
},
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"resolutions": {
"angular": ">=1.2",
"angular-material": "0.x",
"angular-sanitize": "~1.4.3"
}
}
@mcblum When I explicitly declared "angular": "1.4.7"
in resolutions and ran bower install --force-latest
, it worked for me. I was also using the latest version of angular material (1.x).
Thank you @JoshBargar! 1.4.7 did it!
@mcblum no problem. Glad I could help!
+1 Same problem here. I can't switch to latest Angular though. I'm using 1.3.15
I created a new directive containing an md-data-table. When trying to enable the row selection and bind an array to it, an error occurs, and the selection array will always be empty. Currently, the directive's controller is basically empty. The modelData is a directive argument, and the table shows up fine, but the selection array's always empty.
Content of the directive's html:
I've tried to declare an empty array inside the directive's controller, but that didn't work. I also tried to put an empty array inside the controller which owns the scope, where the directive is invoked but that didnt work either.
What am i doing wrong ? Please help.