简体   繁体   中英

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...

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

Try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM