我正在寻找相当于react-dom/server.renderToString
import { renderToString } from 'react-dom/server';
// Render the component to a string
const html = renderToString(
<App />
);
使用NodeJ将指令/组件转换为HTML的最简单的代码示例是什么?
我想应该可以使用其中一个软件包:
@ angular / compiler - v2.0.0-rc.2
@ angular / platform-server - V2.0.0-rc.2
答案 0 :(得分:0)
Angular Components使用HTML模板作为开发过程的一部分,但我们实际上将这些模板编译为Javascript而不是HTML,以便将它们呈现给浏览器。
可能对你有帮助的最近的事情就是https://github.com/angular/universal。此项目代表了在服务器上运行Angular组件的最佳方式,其方式是呈现javascript和HTML并通过网络将其传递到浏览器。
我们无法提供一种简单的方法来“渲染”HTML,因为任何类型的“渲染”都涉及整个Angular框架(核心,常见,模板编译)并处理整个组件树。
希望这有帮助!
答案 1 :(得分:0)
var stopDeparturesFetchedCount = 0
func stopDidFetchDepartures(stop: Stop) {
stopDeparturesFetchedCount += 1
if stopDeparturesFetchedCount >= nearbyStops.count {
print("All stops finished loading")
}
}