无法从AngularJS范围获取值
我在AngularJS有一个现有的项目。有一个带有客户端地址的HTML页面。其标记为:无法从AngularJS范围获取值,angularjs,Angularjs,我在AngularJS有一个现有的项目。有一个带有客户端地址的HTML页面。其标记为: <div class="text-left m-t-lg"> <h5> Address </h5> <address> <div ng-show="customerInfo.companyName != ''"><small>{{customerInfo.companyName}}&
<div class="text-left m-t-lg">
<h5>
Address
</h5>
<address>
<div ng-show="customerInfo.companyName != ''"><small>{{customerInfo.companyName}}</small><br /></div>
<div ng-show="customerInfo.customerName != ''"><small>{{customerInfo.customerName}}</small><br /></div>
<div ng-show="customerInfo.address != ''"><small>{{customerInfo.address}}</small><br /></div>
<div ng-show="customerInfo.email != ''"><small><a href="mailto:{{customerInfo.email}}">{{customerInfo.email}}</a></small></div>
</address>
</div>
我的问题在addressHeaderController.js中,我没有看到addressHeaderInfo或info或customerInfo对象。我需要更新这个对象。此对象从何处初始化?我对AngularJS了解不多
控制器:
app.controller('addressHeaderController', ['$http', 'APIService', '$scope', '$stateParams', '$sessionStorage', '$translate', '$state', '$rootScope', '$timeout', '$locale', 'tmhDynamicLocale',
function ($http, APIService, $scope, $stateParams, $sessionStorage, $translate, $state, $rootScope, $timeout, $locale, tmhDynamicLocale) {
var ctl = this;
$scope.followingAddress = false;
$scope.followData = {};
$scope.issueDisplay = '';
$scope.showResend = true;
$scope.showLoyaltyColumn = $sessionStorage.userObject.clientInfo.showLoyaltyColumnOnSurveyDetail;
ctl.isOpen = false;
ctl.dateOptions = { showWeeks: false };
$scope.businessUnits = null;
$scope.targetDealership = null;
$scope.realignComment = null;
$scope.$watch('addressHeaderInfo', function () {
debugger;
//Where is $scope.addressHeaderInfo coming from?
if (typeof ($scope.addressHeaderInfo) != 'undefined') {
//Some operations here. Not related to assigning anything to $scope.
}
});
function getDepartmentData() {
//No assignment here as well.
}
$scope.resendData = function () {
if ($sessionStorage.clientObject.requiresResendJustification) {
$('#resendJustificationModal').modal('show');
}
else {
var resendData = {};
resendData.recordId = $scope.addressHeaderInfo.addressID;
resendData.statusId = 24;
APIService.postData(resendData, 'Address/UpdateResendStatus')
.then(function (data) {
if (data.status == 200) {
$rootScope.$broadcast('resendRequest');
}
else {
toastr["error"]('Error');
}
});
}
}
$scope.nextAddress = function () {
$rootScope.$broadcast('addressNavigation', $scope.AddressList[$scope.recordNumber]);
$scope.recordNumber = $scope.recordNumber + 1;
}
$scope.previousAddress = function () {
$rootScope.$broadcast('addressNavigation', $scope.AddressList[$scope.recordNumber-2]);
$scope.recordNumber = $scope.recordNumber - 1;
}
$scope.followAddress = function () {
APIService.postData($scope.addressHeaderInfo, 'Address/follow')
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressFollowedSaved'));
$scope.followData = data.data;
$scope.followingAddress = true;
}
else {
toastr["error"]($translate.instant('AddressFollowedErrored'));
}
})
}
$scope.unfollowAddress = function () {
APIService.deleteData('Address/follow/' + $scope.followData.AddressFavoriteId)
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressUnfollowedSaved'));
$scope.followingAddress = false;
}
else if (data.status == 500) {
toastr["error"]($translate.instant('AddressUnfollowedErrored'));
}
});
}
$scope.AddressReminder = function () {
$('#setReminderPopup').modal('show');
}
$scope.saveReminder = function () {
$scope.followData.notificationDate = $scope.followData.displayDate;
APIService.postData($scope.followData, 'Address/follow/reminder')
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressReminderSaved'));
$('#setReminderPopup').modal('hide');
}
else {
toastr["error"]($translate.instant('AddressReminderErrored'));
}
})
}
$scope.realignAddress = function () {
if ($scope.addressHeaderInfo) {
if (!$scope.businessUnits) {
getBusinessUnits();
}
var bu = $scope.addressHeaderInfo.businessUnit;
if (bu) {
bu.realignDisplayName = bu.name + ', ' + bu.shippingCity + ', ' + bu.suppliedBusinessUnitNumber;
}
$scope.realignComment = null;
$('#realignPopup').modal('show');
}
}
$scope.saveRealignRequest = function () {
var realignedAddress = $scope.addressHeaderInfo;
var realignData = {
AddressId: $scope.addressHeaderInfo.AddressID,
businessUnitId: $scope.targetDealership.businessUnitID,
notes: $scope.realignComment
};
APIService.postData(realignData, 'Address/requestRealignment')
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressRealignRequestSaved'));
$('#realignPopup').modal('hide');
realignedAddress.realignmentStatus = 'Pending'; // cause Realign button to disappear and "Realignment is pending" message to show
} else {
toastr["error"]($translate.instant('AddressRealignRequestErrored'));
}
});
}
$scope.$on('advanceToNextIssue', function (event, data) {
if ($scope.AddressList && ($scope.recordNumber < $scope.AddressList.length)) {
$scope.nextAddress();
}
});
}]);
app.controller('addressHeaderController'、['$http'、'APIService'、'$scope'、'$stateparms'、'$sessionStorage'、'$translate'、'$state'、'$rootScope'、'$timeout'、'$locale'、'tmhdynamicale',
函数($http,APIService,$scope,$stateparms,$sessionStorage,$translate,$state,$rootScope,$timeout,$locale,tmhdynamicale){
var ctl=这个;
$scope.followAddress=false;
$scope.followData={};
$scope.issueDisplay='';
$scope.showResend=true;
$scope.showLoyaltyColumn=$sessionStorage.userObject.clientInfo.ShowLoyaltyColumnSurveyDetail;
ctl.isOpen=false;
ctl.dateOptions={showWeeks:false};
$scope.businessUnits=null;
$scope.targetDistributor=null;
$scope.realligncomment=null;
$scope.$watch('addressHeaderInfo',函数(){
调试器;
//$scope.addressHeaderInfo来自哪里?
if(typeof($scope.addressHeaderInfo)!='undefined'){
//此处有一些操作。与为$scope分配任何内容无关。
}
});
函数getDepartmentData(){
//这里也没有作业。
}
$scope.resendData=函数(){
if($sessionStorage.clientObject.requiresResendJustification){
$('#resendjusticationmodal').modal('show');
}
否则{
var resendData={};
resendData.recordId=$scope.addressHeaderInfo.addressID;
resendData.statusId=24;
APIService.postData(resendData,'Address/UpdateResendStatus')
.then(功能(数据){
如果(data.status==200){
$rootScope.$broadcast('resendRequest');
}
否则{
toastr[“error”](“error”);
}
});
}
}
$scope.nextAddress=函数(){
$rootScope.$broadcast('addressNavigation',$scope.AddressList[$scope.recordNumber]);
$scope.recordNumber=$scope.recordNumber+1;
}
$scope.previousAddress=函数(){
$rootScope.$broadcast('addressNavigation',$scope.AddressList[$scope.recordNumber-2]);
$scope.recordNumber=$scope.recordNumber-1;
}
$scope.followAddress=函数(){
APIService.postData($scope.addressHeaderInfo,'Address/follow')
.then(功能(数据){
如果(data.status==200){
toastr[“success”]($translate.instant('AddressFollowedSaved');
$scope.followData=data.data;
$scope.followAddress=true;
}
否则{
toastr[“error”]($translate.instant('addressfollowerderrored');
}
})
}
$scope.unfollowAddress=函数(){
APIService.deleteData('Address/follow/'+$scope.followData.AddressFavoriteId)
.then(功能(数据){
如果(data.status==200){
toastr[“success”]($translate.instant('addressunfollowdsaved'));
$scope.followAddress=false;
}
否则如果(data.status==500){
toastr[“error”]($translate.instant('AddressUnfollowered'));
}
});
}
$scope.addressemployment=函数(){
$('#setrementerpopup').modal('show');
}
$scope.SAVEREMENTER=函数(){
$scope.followData.notificationDate=$scope.followData.displayDate;
APIService.postData($scope.followData,“地址/跟踪/提醒”)
.then(功能(数据){
如果(data.status==200){
toastr[“success”]($translate.instant('addressrementersaved');
$('#setrementerpopup').modal('hide');
}
否则{
toastr[“error”]($translate.instant('AddressRememberErrored');
}
})
}
$scope.reallignAddress=函数(){
如果($scope.addressHeaderInfo){
if(!$scope.businessUnits){
getBusinessUnits();
}
var bu=$scope.addressHeaderInfo.businessUnit;
如果(bu){
bu.reallignDisplayName=bu.name+,“+bu.shippingCity+”,“+bu.suppliedBusinessUnitNumber;
}
$scope.realligncomment=null;
$('reallignpopup').modal('show');
}
}
$scope.saveRealignRequest=函数(){
var realignedAddress=$scope.addressHeaderInfo;
var重新调整数据={
AddressId:$scope.addressHeaderInfo.AddressId,
businessUnitId:$scope.target经销商.businessUnitId,
注意:$scope.realignComment
};
APIService.postData(重新排列数据,“地址/请求重新排列”)
.then(功能(数据){
如果(data.status==200){
toastr[“success”]($translate.instant('AddressRealignRequestSaved');
$('reallignpopup').modal('hide');
realignedAddress.realignmentStatus='Pending';//导致Realign按钮消失,并显示“Realignment is Pending”消息
app.controller('addressHeaderController', ['$http', 'APIService', '$scope', '$stateParams', '$sessionStorage', '$translate', '$state', '$rootScope', '$timeout', '$locale', 'tmhDynamicLocale',
function ($http, APIService, $scope, $stateParams, $sessionStorage, $translate, $state, $rootScope, $timeout, $locale, tmhDynamicLocale) {
var ctl = this;
$scope.followingAddress = false;
$scope.followData = {};
$scope.issueDisplay = '';
$scope.showResend = true;
$scope.showLoyaltyColumn = $sessionStorage.userObject.clientInfo.showLoyaltyColumnOnSurveyDetail;
ctl.isOpen = false;
ctl.dateOptions = { showWeeks: false };
$scope.businessUnits = null;
$scope.targetDealership = null;
$scope.realignComment = null;
$scope.$watch('addressHeaderInfo', function () {
debugger;
//Where is $scope.addressHeaderInfo coming from?
if (typeof ($scope.addressHeaderInfo) != 'undefined') {
//Some operations here. Not related to assigning anything to $scope.
}
});
function getDepartmentData() {
//No assignment here as well.
}
$scope.resendData = function () {
if ($sessionStorage.clientObject.requiresResendJustification) {
$('#resendJustificationModal').modal('show');
}
else {
var resendData = {};
resendData.recordId = $scope.addressHeaderInfo.addressID;
resendData.statusId = 24;
APIService.postData(resendData, 'Address/UpdateResendStatus')
.then(function (data) {
if (data.status == 200) {
$rootScope.$broadcast('resendRequest');
}
else {
toastr["error"]('Error');
}
});
}
}
$scope.nextAddress = function () {
$rootScope.$broadcast('addressNavigation', $scope.AddressList[$scope.recordNumber]);
$scope.recordNumber = $scope.recordNumber + 1;
}
$scope.previousAddress = function () {
$rootScope.$broadcast('addressNavigation', $scope.AddressList[$scope.recordNumber-2]);
$scope.recordNumber = $scope.recordNumber - 1;
}
$scope.followAddress = function () {
APIService.postData($scope.addressHeaderInfo, 'Address/follow')
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressFollowedSaved'));
$scope.followData = data.data;
$scope.followingAddress = true;
}
else {
toastr["error"]($translate.instant('AddressFollowedErrored'));
}
})
}
$scope.unfollowAddress = function () {
APIService.deleteData('Address/follow/' + $scope.followData.AddressFavoriteId)
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressUnfollowedSaved'));
$scope.followingAddress = false;
}
else if (data.status == 500) {
toastr["error"]($translate.instant('AddressUnfollowedErrored'));
}
});
}
$scope.AddressReminder = function () {
$('#setReminderPopup').modal('show');
}
$scope.saveReminder = function () {
$scope.followData.notificationDate = $scope.followData.displayDate;
APIService.postData($scope.followData, 'Address/follow/reminder')
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressReminderSaved'));
$('#setReminderPopup').modal('hide');
}
else {
toastr["error"]($translate.instant('AddressReminderErrored'));
}
})
}
$scope.realignAddress = function () {
if ($scope.addressHeaderInfo) {
if (!$scope.businessUnits) {
getBusinessUnits();
}
var bu = $scope.addressHeaderInfo.businessUnit;
if (bu) {
bu.realignDisplayName = bu.name + ', ' + bu.shippingCity + ', ' + bu.suppliedBusinessUnitNumber;
}
$scope.realignComment = null;
$('#realignPopup').modal('show');
}
}
$scope.saveRealignRequest = function () {
var realignedAddress = $scope.addressHeaderInfo;
var realignData = {
AddressId: $scope.addressHeaderInfo.AddressID,
businessUnitId: $scope.targetDealership.businessUnitID,
notes: $scope.realignComment
};
APIService.postData(realignData, 'Address/requestRealignment')
.then(function (data) {
if (data.status == 200) {
toastr["success"]($translate.instant('AddressRealignRequestSaved'));
$('#realignPopup').modal('hide');
realignedAddress.realignmentStatus = 'Pending'; // cause Realign button to disappear and "Realignment is pending" message to show
} else {
toastr["error"]($translate.instant('AddressRealignRequestErrored'));
}
});
}
$scope.$on('advanceToNextIssue', function (event, data) {
if ($scope.AddressList && ($scope.recordNumber < $scope.AddressList.length)) {
$scope.nextAddress();
}
});
}]);