Eric Mitjans
Eric Mitjans

Reputation: 2179

Problems binding ng-click with ng-show

I'm trying to display an input (and hide another) when a link is clicked.

So far I've tried:

<input ng-if="form.type=='Other'" type="text" class="form-control" placeholder="{{questions.n3B.placeholder}}" ng-hide="editplaceholder == true"/>
<input ng-show="editplaceholder == true" ng-model="questions.n3B.placeholder" type="text" class="form-control"/>
<a href="" ng-if="form.type=='Other' && editMode" class="edit-link" ng-click="EditPlaceholder()"  >Edit placeholder</a>

And the function that gets fired:

var EditPlaceholder = function ($scope) {
$scope.editplaceholder = true;
};

What am I missing?

I'm kinda new in AngularJS and I think that most of my problems come from lack of a solid foundation on the basics...

Upvotes: 0

Views: 30

Answers (1)

Conqueror
Conqueror

Reputation: 4443

You have to add your EditPlaceholder function to the scope in order to call it from ng-click.

Try

$scope.EditPlaceholder = function(...){}

Upvotes: 1

Related Questions