将数据放在动态文本框中不起作用

时间:2016-01-12 05:44:24

标签: javascript angularjs

我无法使用ng-model将数据输入上一页。在填写文本框中的一些数据之后我移动到下一页,在到达同一页面之后,我希望我的数据输入与之前输入的相同,我编写代码但是它不起作用请告诉我我做错了什么并且感谢预先

js代码: -

$scope.notesPage = function() {
        $rootScope.data = {
            Name:               $scope.prospectName,
        };
        $location.path('/prospectNotes');
    };

    $scope.addProspect = function() {
        $rootScope.data.ProspectNotes = $scope.notes;
        $scope.ProspectNotes = "";
    };

    function fillFormData() {
        $scope.prospectName = $rootScope.data.Name;
    }

    $scope.addProspectForm = function() {
        $location.path('/create');
        fillFormData();

    }

    first html page

    <div class = "container" id = "form-container">
            <div class = "form-group">
                <label for = "prospectName"> Prospect Name:
                    <img src = "images/required.gif" alt = "Required" class = "required-star">
                </label>

                <input type = "text" id = "prospectName" name = "prospectName" ng-model = "prospectName"
                       class = "form-control" required>
            </div>

            <div class = "form-group">

                <button type="submit" class="col-sm-2 btn btn-primary" ng-click="notesPage()"
                        style="margin-left:10px;"> Next </button>
            </div>
    </div>

     second html page

     <div class = "container" id = "form-container">

             <div class = "form-group">
                 <label for = "notes"> Notes for Prospect {{data.Name}}</label>
                 <textarea rows="20" id = "notes" name = "notes" ng-model = "notes" class = "form-control"></textarea>
             </div>

             <div class = "form-group">
                 <input type="button" id="cancel-button" value="Back" class="col-sm-2 btn btn-primary"
                        ng-click="addProspectForm()">
                 <button type="submit" class="col-sm-2 btn btn-primary" ng-click="addProspect()"
                         style="margin-left:10px;"> Add </button>
             </div>
     </div>

0 个答案:

没有答案