0

簡単なフォームがあり、色を選択して数量を入力します。送信ボタンをクリックするindex.htmlと、部分的なものを部分的なものに置き換えsubmitted.htmlて、フォームから送信された情報を操作したいと考えています。このSubmittedCtrl情報を使用して API 呼び出しを行い、返されたデータはsubmitted.html部分的に使用されます。

index.html 部分

<form>
    <select ng-model="input.Color" ng-options="product as product.color for product in products"></select>
    <input type="text" ng-model="input.Qty">
    <button ng-click="submit(input)">Submit</button>
</form>

app.js

var myApp = angular.module('myApp', []);

myApp.config(function($routeProvider, $locationProvider) {
    $routeProvider
        .when('/', {
            templateUrl: './partials/index.html',
            controller: 'IndexCtrl'
        })
        .when('/submitted', {
            templateUrl: './partials/submitted.html',
            controller: 'SubmittedCtrl'
        })
        .otherwise({
            template: "404 not found"
        })
});

myApp.controller("IndexCtrl", function($scope, $routeParams) {
    $scope.submit = function(data) {
        $http.jsonp('http://api.remoteserver/' + data.Color.color + '/' + data.Qty + '?callback=JSON_CALLBACK')
                .success(function(result) {
                //how do I get this data loaded into SubmittedCtrl?
        });
    }
});

myApp.controller("SubmittedCtrl", function($scope, $routeParams) {

});
4

0 に答える 0