Javascript calling function without need . click

Asked

Viewed 91 times

1

How can I call this function without having to create a button, for example:

My controller sends a notification to the html of {{error}} or {{Success}} and both are hidden and I want to customize this information before it is displayed

<div class="content" ng-controller="respostasController">
    <div class="alert alert-danger" ng-show="error" class="ng-hide">
        <span>{{error}} </span>
            <button class="close" type="button" ng-click="close()">x</button>
    </div>,
    <div class="alert alert-success" ng-show="success" class="ng-hide">
        <span>{{success}} </span>
            <button class="close" type="button" ng-click="close()">x</button>
    </div>
</div>

I want to take this information {{error}} and {{Success}} and customize it in the script below before displaying on the page

$('#clique').click(function(){

        $.bootstrapGrowl("div 1",{
            allow_dismiss: false,
            type: 'danger'
        });

        $.bootstrapGrowl("div 2",{
            allow_dismiss: false,
            type: 'success'
        });
    });
  • If my div sees 1? Explain better what you want.

  • edited, I think I’ve been able to explain what I’ve been trying to do

1 answer

0

From what I understand, you are using angular to render the page. In this case, you can directly change the variable in $scope. The change is applied directly on the screen, without the click event. You can still set the value of this variable on controller startup.

Example

http://codepen.io/vhkrausser/pen/gwKBxg

  • 1

    you could give an example?

  • @John, I added an example. I hope it helps in your situation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.