Model in a modal window in angularjs is empty

前端 未结 2 1660
耶瑟儿~
耶瑟儿~ 2020-11-30 15:32

Hello I am using angularjs ui bootstrap and I have one text field in a modal window, which when I try to print it in alert window it is empty. Any reasons why? Here is a plu

2条回答
  •  余生分开走
    2020-11-30 16:16

    Try to change the

    • $scope.testField

    into

    • $scope.myModel.testField (or user.firstName...)

    As mentioned in this video angular JS - best practice (29:19):

    "Whenever you have ng-model there's gotta be a dot in there somewhere. If you don't have a dot, you're doing it wrong."

    See updated plunker http://plnkr.co/edit/z1ABPEUB7Nxm1Kxey9iv?p=preview

    NOTE: with a nice reminder of the video-minute from article Nested Scopes in Angular JS

提交回复
热议问题