Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ng-class screwed up #6419

Closed
vavrecka opened this issue Feb 23, 2014 · 19 comments
Closed

ng-class screwed up #6419

vavrecka opened this issue Feb 23, 2014 · 19 comments
Assignees

Comments

@vavrecka
Copy link

having multiple ng-classes does not work, this chunk of code in JADE:
span.glyphicon(class='{{editLogin ? "glyphicon-floppy-save" : "glyphicon-pencil"}}')
this resolves in throwing this error:
TypeError: Object # has no method 'setClass'
at Object.Attributes.$updateClass (http://127.0.0.1:9000/lib/angular/angular.js:5442:20)
at Object.interpolateFnWatchAction as fn
at Scope.$digest (http://127.0.0.1:9000/lib/angular/angular.js:11867:29)
at Scope.$apply (http://127.0.0.1:9000/lib/angular/angular.js:12116:24)
at HTMLButtonElement. (http://127.0.0.1:9000/lib/angular/angular.js:18026:21)
at HTMLButtonElement.jQuery.event.dispatch (http://127.0.0.1:9000/lib/jquery/jquery.js:4371:9)
at HTMLButtonElement.elemData.handle (http://127.0.0.1:9000/lib/jquery/jquery.js:4057:28) angular.js:9475
(anonymous function) angular.js:9475
(anonymous function) angular.js:6920
Scope.$digest angular.js:11886
Scope.$apply angular.js:12116
(anonymous function) angular.js:18026
jQuery.event.dispatch jquery.js:4371
elemData.handle

@Narretz
Copy link
Contributor

Narretz commented Feb 24, 2014

Could you provide a plunkr with the generated markup?

I think your JADE should look like this:

span.glyphicon(ng-class='editLogin ? "glyphicon-floppy-save" : "glyphicon-pencil"')

Note that it's ng-class, and that inside of it is an expression, not an interpolation, so no need for {{}}. But if this is the problem is hard to say without a reproduction.

@linclark
Copy link
Contributor

This issue doesn't provide enough detail to be actionable. You can find an issue template at http://issuetemplate.com/#/angular/angular.js/issue/6407.

Please feel free to create a new issue with more detail, including an example as Narretz mentioned in his comment.

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

Hold up, this is relevant to a fix that was put into 1.2.13. Reopening.

@matsko matsko reopened this Feb 26, 2014
@matsko matsko self-assigned this Feb 26, 2014
@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

@vavrecka did you happen to update angular.js to 1.2.13 but not angular-animate.js ?

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

Also, please continue reading this here: #6460

@matsko matsko closed this as completed Feb 26, 2014
@vavrecka
Copy link
Author

yea, it got screwed up with angular update to the 1.2.14 I think, after 30 minutes I gave up and installed back 1.2.10

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

You mean 1.2.13. Can you quickly just try using 1.2.13 for both files and confirming if the bug is there?

@vavrecka
Copy link
Author

I got 1.2.13 and this code:

ng-class='editAddress ? "glyphicon-floppy-save" : "glyphicon-pencil"'

works well

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

Try

<div ng-init="editAddress = true">
<div ng-class='editAddress ? "glyphicon-floppy-save" : "glyphicon-pencil"' class="glyphicon-floppy-save">
</div>

Now set editAddress to false and see if that error shows up again.

@vavrecka
Copy link
Author

no error, works fine

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

It may have been a bower issue. Please post a comment if anything else comes up.

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

Thanks a bunch!

@vavrecka
Copy link
Author

I think 1.2.14 screwed it up, but it is no longer on Git as I see, did you deleted the release?

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

No, 1.2.14 will be released at the end of the week. If bower downloaded it then it refers to the master branch and it would show up as 1.2.14.

Try using http://code.angularjs.org/snapshot/ or git@github.com:angular/angular.js.git in your bower config to fetch it.

If you can, can you paste your bower config here please?

@vavrecka
Copy link
Author

bower.json:

{
  "name": "frontend",
  "version": "0.8.0",
  "dependencies": {
    "jquery": "~2.1.0",
    "angular": "~1.2.13",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "angular-route": "1.2.6",
    "angular-resource": "~1.2.9",
    "angular-animate": "~1.2.9",
    "angular-ui-router": "0.2.8-bowratic-tedium",
    "ckeditor": "*",
    "angular-bootstrap": "~0.10.0",
    "angular-sanitize": "~1.2.9",
    "nprogress": "~0.1.2",
    "ngAnimate-animate.css": "~0.1.1",
    "ngScrollTo": "*",
    "momentjs": "~2.5.1",
    "bootstrap": "~3.1.1",
    "bootstrap-switch": "~2.0.1",
    "angular-bootstrap-switch": "~0.2.1",
    "jasny-bootstrap": "jasny/bootstrap#~3.1.0",
    "ng-file-upload": "~1.2.8",
    "async": "~0.2.10"
  },
  "devDependencies": {
    "angular-mocks": "1.2.6",
    "angular-scenario": "1.2.6"
  },
  "resolutions": {
    "jquery": "~2.1.0",
    "bootstrap": "~3.1.1",
    "bootstrap-switch": "~2.0.1"
  }
}

and bower installed this version of angular:
#1.2.14-build.2329+sha.c914cd9
On this version it didnt work, but it works now as well, so this might be another of the "magical bugs" :-)

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

So when you say now, do you mean on the latest 1.2.14~ build?

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

Keep in mind that the other issue was because of bower: #6460 (comment)

@vavrecka
Copy link
Author

Oh! Awesome, yep, I have the latest 1.2.14~ build and everything works fine. Thanks for the help. I appreciate it.

@matsko
Copy link
Contributor

matsko commented Feb 26, 2014

Awesome. Thanks!

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

No branches or pull requests

5 participants