【问题标题】:Pass data from one html page to another html page in angularJS将数据从一个html页面传递到angularJS中的另一个html页面
【发布时间】:2026-02-23 06:25:04
【问题描述】:
var mainApp=angular.module('myMainApp',['ngRoute']);
mainApp.config(['$routeProvider',function($routeProvider){

    $routeProvider.when('/showData',{
    templateUrl:'C:/Users/Lala/Desktop/angularjs_lala/PassDatatoAnotherSecondPage.html',
    controller:'MainPageController'
    }).

     otherwise({
    redirectTo: 'file:///C:/Users/Lala/Desktop/angularjs_lala/PassDatatoAnotherPage.html'
  });
  }]);

        mainApp.controller('MainPageController',['$scope',function($scope){         

        console.log("In controller");

        $scope.SubmitData=function(user){

            console.log("In function");
            $scope.userData={
                  Fname:user.name,
                  Lname:user.surname,
                  Mobno:user.Mobno,
                  City:user.city
            };
            console.log($scope.userData);
            //$state.go('file:///CC:/Users/Lala/Desktop/angularjs_lala/SubmitPassedData.html');
        };
    }]);

【问题讨论】:

标签: javascript html angularjs


【解决方案1】:

您可以通过多种方式传递数据。

  1. 浏览器的localStorage
  2. 网址参数
  3. 服务器端会话
  4. Cookie,如今已过时且效率低下。

您可以参考以下链接了解详情。

How to pass data from one html page to another in angularJS?

【讨论】:

    最近更新 更多