如果有人说的话,请原谅我不理解这一点.
为什么Angpen实现的Dependency Injector通过a使用注射剂
constructor?
我习惯以DI各种方式看待.即使是一种静态方法也是有意义的(如果存在对不起我还没挖到那么深,我到目前为止已经进入了一周).
以这种方式使用它会不会更容易或更合乎逻辑,更类似于我们经常看到但仍然在构造函数中传递它的DI?
// Non-Angular Example
@Component({})
class FooComponent {
public appState: AppState;
constructor(DI: DependencyInjector) {
this.appState = DI.get('AppState');
}
ngOnInit() {}
}
Run Code Online (Sandbox Code Playgroud)
Angular更像是这样,我不确定它是仅仅是为了冗长,还是有其他原因.
// Angular 2/4 Example
@Component({})
class BarComponent {
public appState: AppState;
constructor(appState: AppState,
router: Router,
etc: EtcSomething) {
}
ngOnInit() {}
Run Code Online (Sandbox Code Playgroud)
我知道谷歌已经想到了这一点,我只是想了解推理和/或好处.也许我醒来时想到了愚蠢的事情,这很明显,只是我的头脑,但我错过了.
我希望我所要求的是有道理的,我只是想知道为什么.
我需要获取以下日期格式。
30th July 2019
Run Code Online (Sandbox Code Playgroud)
我尝试什么
<time-zone time="{{ 2019-07-31 18:30:00 }}" format="DD MMM YYYY"></time-zone>
Run Code Online (Sandbox Code Playgroud)
结果 : 2019 年 8 月 1 日
我使用Angular2来限制文本框中的复制和粘贴.但是我如何编写自定义指令,以便它可以很容易地应用于所有文本字段.
以下是限制复制和粘贴功能的工作代码.
<ion-input formControlName="confirmpass" type="tel" (cut)="$event.preventDefault()" (copy)="$event.preventDefault()" (paste)="$event.preventDefault()"></ion-input>
Run Code Online (Sandbox Code Playgroud) 下面的代码在localhost上工作正常,但在microsoft azure上部署我的api后得到上面的错误.
我的代码如下:
public class UsersController : Controller
{
private readonly HttpClient _client;
public UsersController()
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
_client = new HttpClient { BaseAddress = new Uri("https://pincode.saratchandra.in/api") };
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public JsonResult GetAddress(int pincode)
{
var response =_client.GetAsync("/pincode/125112").Result;
//Here it throws an exception: got no response
if (response.IsSuccessStatusCode)
{
}
return Json(ApiResult.Success(), JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
没有得到任何响应上面的电话只是得到错误
请求已中止:无法创建SSL/TLS安全通道
在运行“ng test”命令时将 angular 7 项目转换为 angular Universal,错误为“ Incomplete: No specs found, , randomized with seed 48751”。尝试了不同的方式提及 stackoverflow,但对我来说没有任何作用。
ERROR in ./src/polyfills.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: ../src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (../node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/angular_compiler_plugin.ts:1024:15)
at plugin.done.then (../node_modules/@ngtools/webpack/src/packages/ngtools/webpack/src/loader.ts:49:29)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ multi ./src/polyfills.ts ./node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/jit-polyfills.js polyfills[0]
Run Code Online (Sandbox Code Playgroud)
预期输出为 ng test 命令正常运行而不会出现任何问题,以便我的单元测试用例执行。
我需要使用开始和结束行号从 excel 中提取图像。并开始 && 结束 col no
我目前的代码如下:-
var excelApp = new Application();
var wb = excelApp.Workbooks.Open(filePath, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
var ws = (Worksheet)wb.Worksheets["Sheet1"];
int startCol = 0;
int startRow =0;
int endCol = 0;
int endRow = 0;
foreach (var pic in ws.Pictures())
{
int startCol = pic.TopLeftCell.Column;
int startRow = pic.TopLeftCell.Row;
int endCol = pic.BottomRightCell.Column;
int endRow = pic.BottomRightCell.Row;
}
Run Code Online (Sandbox Code Playgroud)
当所有图像都不同时,上面的代码工作正常,但是当我将相同的图像放在不同的单元格中时,它只选择第一个。
例如,当我put abc.jpeg at B1 cell …
我有两个不同的div和基于下拉选择如果是general-1 div show和general-2 div hide,如果选择No general-2 div show和general-1 div hide.
请使用angular js为我提供正确的解决方案,我的示例代码如下所示.
我是角度Js的新手,所以请为我提供简单的方法来解决这个功能,以便更多地达到这个代码.
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div class="col-md-12" style="padding:5px">
<div class="col-md-12">
<label class="label-head">Phd Guide</label>
<select name="phd_guide" class="form-control" required ng-model="myVar">
<option value="">---Choose Phd Guide---</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</div>
</div>
<div class="col-md-12" style="padding:5px" id="general-1" ng-hide="myVar">
<div class="col-md-3">
<label class="label-head">Guide since</label>
<input type="text" class="form-control" name="guide_since" placeholder="Guide Since" required>
</div>
<div class="col-md-3">
<label class="label-head">Present Phd Scholars</label>
<input type="text" class="form-control" name="phd_scholar" placeholder="Phd Scholar" required>
</div>
<div class="col-md-3">
<label …Run Code Online (Sandbox Code Playgroud)