0

I have found this demo in (jsfiddle), One thing I am not sure is the okay button they have

<button ng-click="activity.isEdited = false">Ok</button>

With this function, I am wondering if we can still add a function inside the ng-click? with something like this?

<button ng-click="domeSomthing()">Ok</button>

Can we include both activity.isEdited = false and domeSomthing()inside the ng-click?

3 Answers 3

2

Why not have a scope function that does both?

function doSomething() {
    alert('Done editing');
}
$scope.editedActivity = function(activity) {
    activity.isEdited = false;
    doSomething();
}

and in HTML

<button ng-click="editedActivity(activity)">Ok</button>

Fiddle: http://jsfiddle.net/A5xZ9/4/

Sign up to request clarification or add additional context in comments.

Comments

1

Try:

<button ng-click="activity.isEdited = false; domeSomthing();">Ok</button>

Comments

1

Sure can!

Just add your function to the controllers scope or to a directive. Then you can call it in the ng-click. To use both the function and the Boolean just separate them with a semi-colon

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.