我正在尝试在我的角度应用程序中调试相当复杂的模块.我在一个特定方法的开头设置了一个断点,希望我可以跟进它,看看它给了我一个错误.但是,它一直让我进入VM脚本(VM28337,VM30559等).我可以假设这些都是应有的,所以我没有兴趣看到它们.
我知道我可以在chrome调试器中对某些脚本进行blackbox,但似乎有无数的这些VM脚本.有没有人对如何绕过这些脚本有任何建议?
我遇到的问题仅在上个月左右才开始发生.网络选项卡中的http请求日志在初始页面加载后停止记录请求.我知道在某些情况下可能需要这种行为,但就我而言,它并不是很有用.我在初始页面加载后发出了几个http请求,除非我记得要记录,否则我不会在日志中看到任何内容.
这是其他人有问题吗?是否有一个可以纠正这个问题的地方?
试图清除超时但它不起作用。console.logging 它在初始化和销毁后返回一个数字。
const timer = setTimeout(() => {});
console.log('initialised', timer); // initialised 22
clearTimeout(timer);
console.log('destroyed', timer); // destroyed 22Run Code Online (Sandbox Code Playgroud)
我期待第二个日志返回空值。我也没想到计时器是一个简单的数字。我原以为它是一个对象。clearTimeout 是否在做它应该做的事情?
我正在尝试独立于 AGM 地图模块加载谷歌地图 API。我尝试这样做是因为在某些情况下我想在不使用 AGM 模块的情况下访问 Google Maps API。例如,如果我想加载街景,我需要调用 Google Maps 服务,我希望 API 已经加载并可以使用。出现问题是因为 app.module 中的 AgmCoreModule 负责加载 Google API,如下所示:
AgmCoreModule.forRoot({
apiKey: 'API_KEY',
libraries: ['places', 'drawing', 'geometry']
})
Run Code Online (Sandbox Code Playgroud)
这适用于使用 AGM 组件加载地图。该脚本被附加到 index.html 文件,一切正常。但是,如果我想在没有实例化地图的情况下访问 Google Maps API,则 AGM 模块未附加 Google API 脚本并且“google”未定义。
有没有一种方法可以在不使用 AgmCoreModule 上的 forRoot() 函数的情况下加载 Google Maps API?
我在 Angular 5 项目中使用 UI Router。当运行页脚组件的测试时,我收到此错误:
Failed: Unexpected value 'StateService' declared by the module 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.
Run Code Online (Sandbox Code Playgroud)
但是,我正在导入 StateService 并将其包含在 TestBed 的声明数组中。
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FooterComponent } from './footer.component';
import { StateService } from '@uirouter/angular';
fdescribe('FooterComponent', () => {
let component: FooterComponent;
let fixture: ComponentFixture<FooterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ StateService ],
declarations: [ FooterComponent ],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(FooterComponent);
component = fixture.componentInstance;
fixture.detectChanges(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试显示一个包含换行符和换行符的 json 字符串;\r和\n
这是json:
{
"Content": "OFCH\r\nPVC Double Glazed Windows\r\nMains Services"
}
Run Code Online (Sandbox Code Playgroud)
这是 HTML:
<p class="PropertyBrochure__DescriptionContent" [innerHTML]="description.Content"></p>
Run Code Online (Sandbox Code Playgroud)
这是输出:
OFCH PVC Double Glazed Windows Mains Services
Run Code Online (Sandbox Code Playgroud)
如您所见\r\n,json 字符串中的 被剥离并被忽略。我错过了什么吗?
angular ×3
angularjs ×1
debugging ×1
google-maps ×1
javascript ×1
karma-runner ×1
unit-testing ×1