2019/10/28 summary

1. AngularJS which uses two HTTP request and $ a second to be performed after the first, then executing the process as shown in the following example:

 1 this.$http.post<IApiResponse<number>>(this.routeConfig.postNewExam(), this.newexam(reviewApproved))
 2             .then(resp => {
 3                 if (this.newExamOrNot) {
 4                     this.newExamId = resp.data.Result;
 5                     this.finalResult = this.newExamId.toString();
 6                 }
 7                 else {
 8                     this.finalResult = this.selectedExam.Id.toString();
 9                 }
10                 var ExamID = this.finalResult;
11                 return ExamID;
12             },
13                 err => this.errorHandler.apiError(err))
14             .then(ExamID => {
15                 this.$http.get<IApiResponse<any>>(this.routeConfig.exam(ExamID))
16                     .then(resp => {
17                         if (!resp.data.Result || resp.data.Result.Id != Number(this.finalResult))
18                             return;
19                         if (resp.data.Result.Forms != null) {
20                             this.FormList = new Array<string>(this.selectedExamForms);
21                             for (var i = 0; i < this.selectedExamForms; i++) {
22                                 this.FormList[i] = resp.data.Result.Forms[i].key.FormDesc;
23                             }
24                         }
25                     });
26             },
27                 err => this.errorHandler.apiError(err));
View Code

The first $ http request then two, then get the first result of a $ http request, the second then a second $ http request is executed (can be called the first result $ http request).

 

2. How does a controller and a parent-child value directive directly transmitted (passed directive controller), a method as shown in the following example:

 1 export let ddiIframeDirective = function (): ng.IDirective {
 2      
 3     return {
 4         restrict: 'AE',
 5         scope: {
 6             imgPath: '@'
 7         },
 8         controllerAs: 'iframeCtrl',
 9         controller: ['$sce', '$scope', function ($sce, $scope) {
10             $scope.filter = function () {
11                 return $sce.trustAsResourceUrl($scope.imgPath);
12             };
13         }],
14         template: `<div style='padding-top: 25px'>` +
15             `<iframe height='500' width='450' ng-src='{{filter(imgPath)}}'></iframe>` +
16         `</div>`
17     };
18 };
              <ddi-iframe-directive img-path={{link}}></ddi-iframe-directive>

link controller within the variable, received values ​​within the scope of the directive, and then through the filter so that the local controller within the image file can be displayed directive template. But local files only Edge display, Chrome for security reasons to suppress the local file path, so to change the file virtual address on IIS.

 

How to convert within 3. Javascript string date for the date format, the direct use new Date will not be correct, because the time zone issues, the date should be separated within the string to the following example shows:

var parts ='2014-04-03'.split('-');
// Please pay attention to the month (parts[1]); JavaScript counts months from 0:
// January - 0, February - 1, etc.
var mydate = new Date(parts[0], parts[1] - 1, parts[2]); 

 

Guess you like

Origin www.cnblogs.com/shoukaku/p/11756333.html