1

I have a checkbox. On tick of that checkbox, I am displaying a textbox and a drop-down menu. I want to add a submit button which should also be displayed on tick of the checkbox only. This is not working for me. Also, I have to send data (value of textbox and selected value from dropdown) to my controller.js using that submit button. Edited : What i need to do is i have to select data from dropdown and enter text data and I need to send both data to spring controller through angularjs controller.

Here is my code : .html

    <div class="form-group">
            <div ng-controller="release">
                    <div class="col-md-2 col-centered col-fixed">
                        <label for="cloneRelease" translate="release.form.cloneRelease">CloneRelease</label>
                        <input type="checkbox" id="cloneRelease" ng-model="ticketed">
                            <div ng-show="ticketed">
                                Release Name:<input type="text" ng-show="ticketed" id="newReleaseName">
                                Release To Clone<select ng-show="ticketed" ng-repeat="release in releaseName">
                                <option  value={{release}}>{{release}}</option>
                                </select>
                                <button type="submit" class="btn btn-default" translate="" data-dismiss="modal" 
                                ng-click="cloneRelease(release,newReleaseName)">CloneRelease</button>
                            </div>
                    </div>
                </div>
        </div>

controller.js

$scope.cloneRelease = function($release,$newReleaseName){
            var dataObj = {
            oldReleaseName : $scope.release,
            newReleaseName : $scope.newReleaseName,
        };
        console.log('inside clone release'+dataObj);
        $http.post('cloneReleaseController/cloneRelease',dataObj).success(function (data) { 

        }); 
        }

Spring controller

public void cloneRelease(String oldReleaseName ,String newReleaseName, @RequestBody ReleaseDAO releaseDAO){
        System.out.println("inside clone controller"+oldReleaseName+" "+newReleaseName);
}
2
  • maybe use ng-show="ticketed==true" // only show button if checkbox is true. Don't you do this on the other checkbox? Commented Sep 2, 2015 at 10:07
  • No its not working. ng-show="ticketed==true" Its not working Commented Sep 2, 2015 at 10:11

1 Answer 1

1

Please do this one

<div ng-controller="release">
  <div class="col-md-2 col-centered col-fixed">
    <input type="checkbox" id="cloneRelease" ng-model="ticketed">
    <div ng-show="ticketed">
      <input type="text" ng-show="ticketed" id="newReleaseName" ng-model="releaseName">
      <select ng-show="ticketed" ng-repeat="release in releaseName">
        <option  value={{release}}>{{release}}</option>
      </select>
      <button type="submit" class="btn btn-default" translate="" data-dismiss="modal" ng-click="cloneRelease()">CloneRelease</button>
    </div>
  </div>

<div ng-show="ticketed">
  <button type="submit" class="btn btn-default" translate="" data-dismiss="modal" ng-click="cloneRelease()">CloneRelease</button>
</div>
Sign up to request clarification or add additional context in comments.

7 Comments

I can't put submit button in same div tag as there are other fields too. Is there any way to put submit button in other div tag and bind it with checkbox?
I am passing data from angularjs controller to spring controller but its not reaching to the controller.
on submit button you can call function in controller
Its comming to angularjs controller but its not reaching spring controller.
i cannot figure out what is issue? hide button or passing data to spring controller?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.