I've hit a roadblock with something that should be simple. I was planning on creating a factory to tackle this issue, but then I realized there might be a more elegant solution.
In my directive templateUrl, I have an ng-repeat:
<div ng-repeat="item in items">
<p ng-click="toggle()" ng-hide="display">{{item.$value}}</p>
<input ng-model="item.$value" ng-show="display">
<button ng-show="display" ng-click="changeText(item)">finish</button>
</div>
This is what my toggle function looks like:
$scope.toggle = function (){
$scope.display = !$scope.display;
};
So, when I click on one <p>
element, all input fields are displayed because they use the same variable. I'm struggling to find a proper angular solution that would only toggle the field within the item itself. Is there a solution out there for this dilemma?