问题标签 [angular-universal]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular - 在 Angular2 中获取“nativeElement.querySelector 不是函数”异常
我正在尝试访问 Angular2 中的 div,如下所示:
但我得到以下异常:
异常:调用节点模块失败并出现错误:TypeError:this.elementRef.nativeElement.querySelector 不是函数
node.js - 在 Windows 服务器上部署 angular2 通用
我正在为一个新项目评估 Angular2 Universal。我玩过Universal-starter和aspnetcore-angular2-universal以与 asp.net 核心一起使用(目前决定不使用核心,因为在服务器端操作标题和头部标签不可用此时此刻)。然而,尽管 Angular Universal 很吸引人,但我似乎找不到关于如何在 Windows 服务器上部署和运行生产 Angular Universal 网站的完整指南。我有一个服务器来托管我的 .net web-api,我也想在那里托管 angular。(我必须提到我是 angular2 的新手,这是我使用该框架的第一个项目)。
我需要如何以及在服务器上配置什么?(我需要安装 node\npm 吗?)我需要从构建中获取什么以及将它放在哪里?(我的文件夹中有两个文件夹dist
——client
而且server
——它们去哪儿了?)
node.js - 如何在 Angular Universal 中使用 HTTP Node.js 请求
我想将 AngularJS 项目移动到 Angular Universal。
在 AngularJS 中,我有使用 PHP 的 $http 请求。例如,我在服务中有以下代码:
现在,当我将 Node.js 与 Universal 一起使用时,我想将 Http 请求与 Node.js 一起使用。
所以在组件的构造函数中我应该使用构造:
如果我会使用 JSON 文件,那么我会发现很多这样的例子:
但是我所有的数据都在现有的 MySQL 数据库中。所以我想了解如何访问数据库中的数据。
我已经安装了 npm MySql 组件
npm 安装 mysql
我发现与 Node.js 的连接是通过以下方式设置的:
如果我在组件的构造函数中使用此连接代码,则会返回一些错误,例如
那么如何将连接代码与 http.get() 请求集成呢?
非常感谢。
补充:现在我来到了这个(它涉及我的 Angular Universal https://github.com/angular/universal-starter的入门项目):
在组件中,我使用以下代码:
导出类 HomeComponent {
/li>
2.在backend/api.ts我添加了:
如果Mydata是 JSON,那么一切正常,我收到数据。但是我想连接到 MySQL 数据库。所以我添加了一个连接代码:
在这里我收到错误:
然后
如果有人知道如何修复与数据库的连接,我将非常感谢您的建议。
mysql - 在 Angular Universal 中将 MySQL 数据库与 Node.js 连接时出错。TypeError:无法读取未定义的属性“on”
我想在我的 Angular Universal 项目中通过 Node.js 连接到 MySQL 数据库。
连接代码很简单:
首先,我收到以下错误:
然后几秒钟后出现以下错误:
请告诉我在这种情况下应该做些什么来解决这个问题。
非常感谢。
node.js - Angular-universal - 生产问题
我参考这个Angular GitHub Repository创建了 Angular-universal 应用程序。我使用 node express 进行服务器端渲染。
我已经使用这个命令构建了
现在我在 dist 文件夹中获得了客户端和服务器文件夹。那里没有其他文件,例如index.html
.
以前我使用 CLI 开发了 angular2 应用程序,在构建它时,它会创建一个包含 、 和 CSS 文件的 dist 文件bundle.js
夹index.html
。我曾经将那个特定的东西上传到共享主机。该应用程序运行良好。但是在角度通用中我很困惑。我被困在如何进一步进行生产。我有共享主机,请帮助我如何在共享主机中托管项目。
javascript - 角通用饼干消失了
angular2-universal - 通用 - 普通 cookie
检查上面的链接,看看有 cookie API,但我找不到它或无法在 angular2 应用程序中添加。我检查了文档,甚至谷歌都找不到它:/它是重命名还是有其他使用方法?
任何人都可以帮助我使用 jsfiddle 或任何有关如何使用它的示例吗?
angular - Angular(4.0.0-beta.8)测试组件夹具在使用子组件执行测试后未定义
我真的不知道发生了什么,但是在测试我的 Angular 代码时我有一个非常奇怪的行为。我只是在进行设置,大多数事情都可以正常工作,但如果我在 TestBed.configureTestingModule 的声明中定义了子组件,则不会。describe 中的第一个测试有效,该测试之后的所有其他测试,即使在另一个文件中,也不再有效,因为 fixture = TestBed.createComponent(component); 没有被执行(我假设,因为夹具未定义)
当然,我在某个地方犯了一个大错误,但是在哪里?我这里有一个项目,你可以看到所有的设置。
https://github.com/damirkusar/AngularMeetsNetCore/tree/AngularTesting 这个类解决了问题:navigation.spec.ts
这是在 navigation.specs 之后出现的测试错误示例。删除 navigation.spec 测试以下测试有效。
angular - Unable to find plugin: videoJsResolutionSwitcher in angular2-universal
In the first implementation, I used angular2 without server rendering for creating a web player with video.js library and it's "videojs-resolution-switcher" plugin.
I created a directive for initializing videojs element based on component ngOnInitView and load js files directly in base html file (end of body).
Everything was correct and player worked as expected.
Then I started to setting up angular2-universal and server rendering. There was some problems about using browser specific features that I handled them with "isBrowser" tool.
But now I have a problem with videojs-resolution-switcher. Even with old configs in browser's console the error is:
I tried to require the videoJsResolutionSwitcher in directive, but it returns empty object (because it's not exported). Then I changed the plugin code to export the function but nothings changed just the error about updateSrc function was resolved.
I tried to import js file like this:
But at the compile time an error raised about "undefining window" in videojs resolution switcher code.
videojs.ts directive:
UPDATE
After a lot of testing scenarios, I solved this issue with removing "let videojs = require('videojs');" and adding this custom typings definition:
But I'm looking to know conceptually, what was the reason of this behavior?
angular - 将 Dom 元素动态添加到预渲染的 Angular2 通用页面
我最近切换到 angular2 Universal 以使我的 SPA 被搜索引擎抓取,Angular Universal 非常适合做这个用例,当我尝试为每个页面注入动态元数据时遇到问题,我尝试使用 ElementRef 和 Renderer ,并且我使用了一些angular2-meta服务,但是当平台不是浏览器时它不起作用
以下代码是我最近的尝试
当我将代码包装在构造函数中时
if(isBrowser)
,它只在客户端呈现,但是当我查看页面的源代码时,它没有呈现
当我尝试使用渲染器the this.renderer.createElement
功能进行渲染时不起作用
在将页面发送到客户端之前,是否有任何解决方案或想法可以在服务器中呈现元标记,我正在使用ASP.NET Core 1.1的Angular Universal
提前致谢
mysql - Angular Universal 中的异步 Node.js 请求。服务器渲染停止工作
我用 Node.js 对 Angular Universal 项目中的 MySQL 数据库做了一个简单的请求。
我收到数据,但是,它没有出现在 HTML 模板中。我只看到:
Angular Universal 似乎不会等待从请求中接收数据到数据库。
如果有人知道如何解决该问题,我将不胜感激。谢谢你。