AngularJS ng-model $scope in ng-repeat is undefined

后端 未结 4 1920
有刺的猬
有刺的猬 2020-12-04 18:24

I apologize in advance if i\'m not wording this properly. I have a textbox with ng-model inside an ng-repeat and when I try to get the textbox valu

4条回答
  •  清歌不尽
    2020-12-04 19:09

    In your click expression you can reference the postText and access it in your savePost function. If this wasn't in an ng-repeat you could access the single $scope.postText successfully but ng-repeat creates a new scope for each item.

    Here is an updated fiddle.

    {{post}} save post
    $scope.savePost = function(post){ alert('post stuff in textbox: ' + post); }

提交回复
热议问题