我在函数 1 中初始化了 4 个全局变量,并为函数赋值。当我尝试访问下一个函数中的变量时,只有第一个变量可以访问。所有其他内容均未定义。
当用户填写基本表单信息时调用 Function1。然后,他被重定向到高级表单。填写完两个表格后,数据将存储在数据库中。
请提供一些解决方案。
<!-- language: lang-js -->
`````
<!--'Postspace.js' File-->
function function1() {
window.name = $scope.data.name;
// window.email = 'c@g.com';
window.varemail = $scope.data.email;
window.varmobile = $scope.data.mobile;
window.varlocation = $scope.data.location;
console.log(window.name);
console.log(window.varemail);
console.log(window.varmobile);
console.log(window.varlocation);
}
function function2() {
console.log(window.name);
console.log(window.varemail);
console.log(window.varmobile);
console.log(window.varlocation);
'name': window.name,
'email': window.varemail,
'mobile': window.varmobile,
'location': window.varlocation,
'working_space': $scope.workingSpace.category,
'no_of_persons': $scope.noOfPerson,
'joining_date': $scope.startDate,
'working_hours': workingHours,
'period': $scope.period,
'multipleDays': $scope.multipleDays,
}
>
> form.blade.php file
> I am taking the values in the php file in this format: This is an example of
> how I am accepting the name and the mobile field. `
````
<div class="col-lg-10 col-md-10 form-group" ng-class="{'has-error': LoginForm.fullEmail.$invalid && LoginForm.fullEmail.$touched}">
<p class="form-label ">Your Email</p>
<div class="row ">
<div class="col-lg-8 col-md-8"> <input type="email" ng-model="data.email" name="fullEmail" class="form-control " required placeholder="EMAIL" ng-model-options="{debounce: 200}"></div>
</div>
</div>
<div class="col-md-10 form-group" ng-class="{'has-error': LoginForm.fullmobile.$invalid && LoginForm.fullmobile.$touched}">
<p class="form-label">Your Mobile</p>
<div class="row">
<div class="col-md-8"><input type="text" ng-model="data.mobile" name="fullmobile" class=" form-control" required placeholder="MOBILE" ng-pattern="/^[6-9]{1}[0-9]{9}$/"></div>
</div>
</div>
````
你能展示保存$scope.data对象值的代码吗...