Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic change of table data #2

Open
yarl opened this issue Jun 25, 2014 · 1 comment
Open

dynamic change of table data #2

yarl opened this issue Jun 25, 2014 · 1 comment
Labels

Comments

@yarl
Copy link

yarl commented Jun 25, 2014

If I have data like this:

$scope.tableData = [
                {firstName:"Walter", lastName:"Wurst", age:20},
                {firstName:"Peter", lastName:"Pan", age:21},
                {firstName:"Erwin", lastName:"Erster", age:22},
                {firstName:"Paula", lastName:"Pummel", age:23}
            ];

$scope.tableOptions = {
            data: $scope.tableData
(...)
});

and later want to change data using

$scope.tableData = [
                {firstName:"John", lastName:"Wurst", age:30},
                {firstName:"Anna", lastName:"Pan", age:35}
            ];

the table is not refreshing. Is there a simple way to dynamic change data in table?

@BerndWessels
Copy link
Owner

@yarl Hi, this is the way ui-table monitors changes:

scope.$watch('uiTableOptions', function (newValue) {
    scope.$watch('uiTableOptions.data', function (newValue) {

So in your case I would recommend that you update the uiTableOptions.data property directly to your new data source.

$scope.tableOptions.data = [
                {firstName:"John", lastName:"Wurst", age:30},
                {firstName:"Anna", lastName:"Pan", age:35}
            ];

Cheers
Bernd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants