Submitting an Array of Checkbox Values with AngularJS & Laravel 4. Checkboxes not Checking (Visually)

妖精的绣舞 提交于 2019-12-06 09:11:47

Two Things

I think the problem boils down to just syntax of your code.

  1. Move the ng-controller off the <form> and add it to the div that has ng-app="formApp" (not entirely sure why this works)
  2. Remove the <a> tags surrounding your checkboxes.

Seeing Live Data

Now if you add this to the bottom of your HTML:

<pre>{{ formData }}</pre>

You should be able to see the data change immediately as you change the form.

For example, when I tested I got:

{"test_message":"test","items":{"4":true,"5":true,"6":true}}

Future Stuff

For the future, you'd probably want to move the Blade stuff out of there and pull all the data with $http. This just ensures that in the future if you come back to look at the code, you know 100% that it all came from your JS code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!