-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Error classString.split is not a function #16697
Comments
This error can happen if you are binding This is incorrect usage, but we should handle this more gracefully indeed 😁 |
Thanks George, your comment helped me to find and solve the problem. I think the most important point is that you document somewhere that that error is related to ng-class, so that the developer knows what to look at. |
Glad you solved it. BTW, looking at the stack trace, it should be easy to find out that the error happens inside |
Previously, when an `ngClass` expression evaluated to something that was not a string, array or object (and was truthy), an error would be thrown while trying to call `.split()` on a non-string value. This error was not very helpful for the user to identify the root cause of the problem. This commit fixes it by ensuring such values are converted to string. Fixes angular#16697
Previously, when an `ngClass` expression evaluated to something that was not a string, array or object (and was truthy), an error would be thrown while trying to call `.split()` on a non-string value. This error was not very helpful for the user to identify the root cause of the problem. This commit fixes it by ensuring such values are converted to string. Fixes #16697 Closes #16699
We've had this bug for 4 years. It didn't harm anything, but by saying it was related to ng-class helped me locate which one and fix it. I feel like a million bucks! |
for me it was when should have been |
I'm submitting a ...
Current behavior:
Log trace in the console :
TypeError: classString.split is not a function
at split (angular.js:27114)
at updateClasses (angular.js:27043)
at ngClassWatchAction (angular.js:27085)
at Scope.$digest (angular.js:18585)
at Scope.$apply (angular.js:18945)
at done (angular.js:12799)
at completeRequest (angular.js:13056)
at XMLHttpRequest.requestLoaded (angular.js:12961)
(anonymous) @ angular.js:15018
(anonymous) @ angular.js:11302
$digest @ angular.js:18603
$apply @ angular.js:18945
done @ angular.js:12799
completeRequest @ angular.js:13056
requestLoaded @ angular.js:12961
load (async)
(anonymous) @ angular.js:12944
sendReq @ angular.js:12744
serverRequest @ angular.js:12485
processQueue @ angular.js:17396
(anonymous) @ angular.js:17444
$digest @ angular.js:18557
$apply @ angular.js:18945
(anonymous) @ angular.js:28106
dispatch @ jquery-3.3.1.min.js:2
y.handle @ jquery-3.3.1.min.js:2
Expected / new behavior:
No such log trace.
Minimal reproduction of the problem with instructions:
I have no idea about what is generating the log trace. Maybe it's a misuse of the framework from me, but if so I don't know where my error is.
AngularJS version: 1.7.2
Browser: [all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
I only tested with Chrome.
Anything else:
The text was updated successfully, but these errors were encountered: