How to assign two values in ng-click?

2

I have this html body that will invert the Boolean variable d.expandedBlog when clicked. It is working normally.

<div class="article-blog-icon-comment">
    <i class="fa fa-commenting-o article-blog-menu-topbar" 
    ng-click="d.expandedBlog = !d.expandedBlog" pr-expand-article="d.article.uid"
    expandedBlog="d.expandedBlog"></i>
</div>

But now I want the same html body to also invert the variable d.expanded .

I tried to do this:

<div class="article-blog-icon-comment">
    <i class="fa fa-commenting-o article-blog-menu-topbar" 
    ng-click="d.expandedBlog = !d.expandedBlog, d.expanded = !d.expanded" 
    pr-expand-article="d.article.uid"
    expandedBlog="d.expandedBlog" expanded="d.expanded"></i>
</div>

But it's giving syntax error, I do not know the sintace to do this kind of thing. What could be done here?

    
asked by anonymous 23.08.2018 / 14:52

1 answer

2

You can declare more than one inline mode command in the ng-click directive by separating the commands with ; , just as if you had typed in the normal code:

[...]
ng-click="d.expandedBlog = !d.expandedBlog; d.expanded = !d.expanded" 
[...]

However, I advise you to consider writing a function in the controller to perform these commands for clarity.

    
23.08.2018 / 15:04