我正在寻找PowerShell相当于grep --file=filename.如果您不知道grep,filename是一个文本文件,其中每一行都有您想要匹配的正则表达式模式.
也许我错过了一些明显的东西,但Select-String似乎没有这个选择.
我正在开发一个需要为不同品牌构建和部署的应用程序。大多数差异仅在于 css,我认为我可以在运行时加载正确的样式。
但是,以下方法不起作用:
import { Component, Input } from '@angular/core';
import { brand } from '../../environments/environment';
@Component({
selector: 'app-simple-form',
template: `
<div>
{{message}}
</div>
`,
styleUrls: [`./simple-form.component.${brand}.css`]
})
export class SimpleFormComponent implements OnInit {
@Input() message;
}
Run Code Online (Sandbox Code Playgroud)
请注意我如何导入一个名为brand的字符串,然后使用它来加载正确的样式。但是,在形成styleUrls数组时,品牌不可访问。
但是,一旦组件被渲染,它就可以访问。
任何想法为什么这不起作用,以及是否有推荐的方法?
我有一个AngularJS指令,我正在编写测试.我已经在这个问题中重新创建了这个问题:http://plnkr.co/edit/gHoGwI6TZhsgKVwIb1uI?p = preview
任何人都可以告诉我为什么第二次测试失败以及如何解决它?
码:
var app = angular.module("myApp", []);
app.directive("myDirective", function() {
return {
template: "<div>Hello this is my directive!</div>"
}
});
describe("Testing hidden", function() {
var $compile, $scope, $document;
beforeEach(inject(function(_$compile_, $rootScope, _$document_){
$compile = _$compile_;
$scope = $rootScope.$new();
$document = _$document_;
}));
function getElement() {
var element = angular.element("<div my-directive></div>");
$compile(element)($scope);
return element;
}
it("passes", function() {
var element = getElement();
expect(element.is(":hidden")).toBe(true); // Passes
});
it("fails", function() {
var element = getElement();
$document.body.append(element);
element.show();
expect(element.is(":hidden")).toBe(false); …Run Code Online (Sandbox Code Playgroud)