https://jsbin.com/gazecu/edit?js,console,output
当我粘贴JSON,甚至更改text-area
中的单个字符时,ng-change
成功触发了我控制器中的以下功能
(因为我看到console.log)
$scope.processJSON = function(data){
console.log('data changed');
$scope.rawData = JSON.parse(data);
$scope.displayArray = $scope.ObjArray();
}
但$scope.displayArray
没有重新计算......或者至少它在我的视图中没有更新。
我知道我错过了提醒Angular改变的事情。但是什么?
angular
.module('XMLConverter', [])
.controller('XMLController', XMLControllerFn);
function XMLControllerFn($scope){
$scope.rawData = {
"JOB": {
"-PRO_JOB": "D6C1608473",
"-NOSAMS": "4",
"-PROCSTATUS": "161",
"-PROCSTATUS_TEXT": "Job Complete",
"-CLI_CODE": "24.0",
"-CLI_NAME": "4 HOURLY FLOT FEED/TAIL CON LEACH",
"-CONT_CODE": "PROCESS_MANAGER",
"-RECEIVED": "18/09/2016 16:23:06",
"-REQUIRED": "19/09/2016 16:00:00",
"-COMPLETED": "18/09/2016 16:59:37",
"-FIRSTREPORTED": "18/09/2016 16:59:37",
"-LASTREPORTED": "18/09/2016 16:59:37",
"-INVOICED": "18/09/2016 16:59:37",
"-CCLAS_LABCODE": "UAPREP",
"-XMLMODE": "REPORT",
"SAMPLE": [
{
"-CUID": "0001347486",
"-SAMPLETYPE": "OTHER",
"-SAMPLEIDENT": "1608473-2",
"-SAMPLETIME": "18/09/2016 1100",
"-EXTERNALIDENT": "FLOT_FEED",
"SCHEME": [
{
"-SCH_CODE": "/CSA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/CSA",
"-SHORTNAME": "/CSA",
"ANALYTE": {
"-ANALYTECODE": "S",
"-ANALYTENAME": "S",
"-PI_TAG": "HV_FLOT_FEED_CNTLSOLID_S_pct",
"-NUMERICVALUE": "1.023800015449524",
"-ROUNDEDVALUE": "1.02",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "%",
"-UNITNAME": "%",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "42",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "1",
"-ANASEQUENCE": "4",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "/GRAV",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/GRAV",
"-SHORTNAME": "/GRAV",
"ANALYTE": {
"-ANALYTENAME": "DrySample",
"-NUMERICVALUE": "0.239999994635582",
"-ROUNDEDVALUE": "0.240",
"-REPDETLIMIT": "0.001",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "Kg",
"-UNITNAME": "Kg",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "5000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "2",
"-ANASEQUENCE": "3",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "AR01/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "AR01/AA",
"-SHORTNAME": "AR01/AA",
"ANALYTE": {
"-ANALYTECODE": "AG",
"-ANALYTENAME": "Ag",
"-PI_TAG": "HV_FLOT_FEED_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "14.90999984741211",
"-ROUNDEDVALUE": "14.9",
"-REPDETLIMIT": "0.5",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "ppm",
"-UNITNAME": "ppm",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "100",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "3",
"-ANASEQUENCE": "2",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "FA25/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "FA25/AA",
"-SHORTNAME": "FA25/AA",
"ANALYTE": {
"-ANALYTECODE": "AU",
"-ANALYTENAME": "Au",
"-PI_TAG": "HV_FLOT_TAIL_CNTLSOLID_Au_g/t",
"-NUMERICVALUE": "1.149999976158142",
"-ROUNDEDVALUE": "1.15",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "g/t",
"-UNITNAME": "g/t",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "1000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "4",
"-ANASEQUENCE": "1",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
}
]
},
{
"-CUID": "0001347487",
"-SAMPLETYPE": "OTHER",
"-SAMPLEIDENT": "1608473-3",
"-SAMPLETIME": "18/09/2016 1100",
"-EXTERNALIDENT": "FLOT_TAIL",
"SCHEME": [
{
"-SCH_CODE": "/CSA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/CSA",
"-SHORTNAME": "/CSA",
"ANALYTE": {
"-ANALYTECODE": "S",
"-ANALYTENAME": "S",
"-PI_TAG": "HV_FLOT_TAIL_CNTLSOLID_S_pct",
"-NUMERICVALUE": "0.7418000102043152",
"-ROUNDEDVALUE": "0.74",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "%",
"-UNITNAME": "%",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "42",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "1",
"-ANASEQUENCE": "4",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "/GRAV",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/GRAV",
"-SHORTNAME": "/GRAV",
"ANALYTE": {
"-ANALYTENAME": "DrySample",
"-NUMERICVALUE": "0.2199999988079071",
"-ROUNDEDVALUE": "0.220",
"-REPDETLIMIT": "0.001",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "Kg",
"-UNITNAME": "Kg",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "5000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "2",
"-ANASEQUENCE": "3",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "AR01/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "AR01/AA",
"-SHORTNAME": "AR01/AA",
"ANALYTE": {
"-ANALYTECODE": "AG",
"-ANALYTENAME": "Ag",
"-PI_TAG": "HV_FLOT_TAIL_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "3.674999713897705",
"-ROUNDEDVALUE": "3.7",
"-REPDETLIMIT": "0.5",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "ppm",
"-UNITNAME": "ppm",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "100",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "3",
"-ANASEQUENCE": "2",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "FA25/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "FA25/AA",
"-SHORTNAME": "FA25/AA",
"ANALYTE": {
"-ANALYTENAME": "Au",
"-NUMERICVALUE": "0.1599999964237213",
"-ROUNDEDVALUE": "0.16",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "g/t",
"-UNITNAME": "g/t",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "1000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "4",
"-ANASEQUENCE": "1",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
}
]
},
{
"-CUID": "0001347488",
"-SAMPLETYPE": "OTHER",
"-SAMPLEIDENT": "1608473-4",
"-SAMPLETIME": "18/09/2016 1100",
"-EXTERNALIDENT": "CONC_LEACH_FEED",
"SCHEME": [
{
"-SCH_CODE": "/CSA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/CSA",
"-SHORTNAME": "/CSA",
"ANALYTE": {
"-ANALYTECODE": "S",
"-ANALYTENAME": "S",
"-PI_TAG": "HV_CONC_LEACH_FEED_CNTLSOLID_S_pct",
"-NUMERICVALUE": "7.076700210571289",
"-ROUNDEDVALUE": "7.08",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "%",
"-UNITNAME": "%",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "42",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "1",
"-ANASEQUENCE": "4",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "/GRAV",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/GRAV",
"-SHORTNAME": "/GRAV",
"ANALYTE": {
"-ANALYTENAME": "DrySample",
"-NUMERICVALUE": "0.2800000011920929",
"-ROUNDEDVALUE": "0.280",
"-REPDETLIMIT": "0.001",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "Kg",
"-UNITNAME": "Kg",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "5000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "2",
"-ANASEQUENCE": "3",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "AR01/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "AR01/AA",
"-SHORTNAME": "AR01/AA",
"ANALYTE": {
"-ANALYTECODE": "AG",
"-ANALYTENAME": "Ag",
"-PI_TAG": "HV_CONC_LEACH_FEED_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "169.8899993896484",
"-ROUNDEDVALUE": "169.9",
"-REPDETLIMIT": "0.5",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "ppm",
"-UNITNAME": "ppm",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "100",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "3",
"-ANASEQUENCE": "2",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "FA25/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "FA25/AA",
"-SHORTNAME": "FA25/AA",
"ANALYTE": {
"-ANALYTECODE": "AU",
"-ANALYTENAME": "Au",
"-PI_TAG": "HV_CONC_LEACH_FEED_CNTLSOLID_Au_g/t",
"-NUMERICVALUE": "10.96000003814697",
"-ROUNDEDVALUE": "10.96",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "g/t",
"-UNITNAME": "g/t",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "1000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "4",
"-ANASEQUENCE": "1",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
}
]
},
{
"-CUID": "0001347489",
"-SAMPLETYPE": "OTHER",
"-SAMPLEIDENT": "1608473-5",
"-SAMPLETIME": "18/09/2016 1100",
"-EXTERNALIDENT": "CONC_LEACH_TK1",
"SCHEME": [
{
"-SCH_CODE": "/GRAV",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "/GRAV",
"-SHORTNAME": "/GRAV",
"ANALYTE": {
"-ANALYTENAME": "DrySample",
"-NUMERICVALUE": "0.2300000041723251",
"-ROUNDEDVALUE": "0.230",
"-REPDETLIMIT": "0.001",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "Kg",
"-UNITNAME": "Kg",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "5000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "2",
"-ANASEQUENCE": "3",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "AR01/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "AR01/AA",
"-SHORTNAME": "AR01/AA",
"ANALYTE": {
"-ANALYTECODE": "AG",
"-ANALYTENAME": "Ag",
"-PI_TAG": "HV_CONC_LEACH_TK1_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "85.15499114990234",
"-ROUNDEDVALUE": "85.2",
"-REPDETLIMIT": "0.5",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "ppm",
"-UNITNAME": "ppm",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "100",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "3",
"-ANASEQUENCE": "2",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
},
{
"-SCH_CODE": "FA25/AA",
"-SCHEMETYPE": "ANALYS",
"-SCHEMENAME": "FA25/AA",
"-SHORTNAME": "FA25/AA",
"ANALYTE": {
"-ANALYTECODE": "AU",
"-ANALYTENAME": "Au",
"-PI_TAG": "HV_CONC_LEACH_TK1_CNTLSOLID_Au_g/t",
"-NUMERICVALUE": "53.599999904632568",
"-ROUNDEDVALUE": "3.60",
"-REPDETLIMIT": "0.01",
"-ANALYTESTATUS": "AP",
"-REPUNITCODE": "g/t",
"-UNITNAME": "g/t",
"-QCMINVALUE": "NULL",
"-QCMAXVALUE": "1000",
"-QCEXPECTEDVALUE": "0",
"-REPORTACTIVE": "-1",
"-QCACTIVE": "-1",
"-SCHSEQUENCE": "4",
"-ANASEQUENCE": "1",
"-STARTED": "18/09/2016 16:58:27",
"-COMPLETED": "18/09/2016 16:58:27"
}
}
]
}
]
}
};
$scope.sample = $scope.rawData.JOB.SAMPLE;
$scope.sampleTime = function() {
return 'Sampletime - ' + $scope.sample[0]['-SAMPLETIME'];
}
$scope.ObjArray = function(){
var sample = $scope.sample;
var ObjArr = [];
var obj;
angular.forEach(sample, function(sample) {
var scheme = sample['SCHEME'];
angular.forEach(scheme, function(x) {
obj= {};
obj.pi_tag = x.ANALYTE['-PI_TAG'] || 'undefined';
obj.num_value = x.ANALYTE['-NUMERICVALUE'];
ObjArr.push(obj);
})
})
return ObjArr;
}
$scope.displayArray = $scope.ObjArray();
$scope.processJSON = function(data){
console.log('new data');
$scope.rawData = JSON.parse(data);
$scope.displayArray = $scope.ObjArray();
}
}