{"id":38903,"date":"2023-05-28T21:17:46","date_gmt":"2023-06-21T23:06:40","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/"},"modified":"2024-04-30T06:25:57","modified_gmt":"2024-04-29T22:25:57","slug":"%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/","title":{"rendered":"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904"},"content":{"rendered":"<h2>\u9996\u5148<\/h2>\n<p>\u6211\u662f@Quramy\uff0c\u5bf9\u4e8eAngular1\uff0c\u6211\u6709\u4e00\u5b9a\u7684\u4e86\u89e3\uff0c\u4f46\u662f\u8fd9\u662f\u6211\u7b2c\u4e00\u6b21\u8ba8\u8bbaAngular2\uff0c\u611f\u89c9\u50cf\u4e2aAngular2\u7684\u65b0\u624b\u3002<\/p>\n<p>\u6211\u4eca\u5929\u60f3\u63a2\u8ba8\u4e00\u4e0bAngular1\u548cAngular2\u7684HTTP\u670d\u52a1API\u4e4b\u95f4\u7684\u533a\u522b\uff0c\u7279\u522b\u662f\u5b83\u4eec\u5bf9\u4e8e\u5f02\u6b65\u5904\u7406\u7684\u7acb\u573a\u4e0a\u7684\u5dee\u5f02\u3002<\/p>\n<h2>\u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e0bAjax\u5b9e\u73b0\u4ee3\u7801\u7684\u5dee\u5f02\u3002<\/h2>\n<p>\u9996\u5148\uff0c\u8ba9\u6211\u4eec\u7528Angular1\u548cAngular2\u5206\u522b\u7f16\u5199\u4e00\u6bb5TypeScript\u4ee3\u7801\u6765\u7b80\u5355\u5730\u901a\u8fc7GET\u65b9\u6cd5\u83b7\u53d6\u5982\u4e0b\u6240\u793a\u7684Pet\u8d44\u6e90\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">export<\/span> <span class=\"kr\">interface<\/span> <span class=\"nx\">IPet<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"nl\">id<\/span><span class=\"p\">:<\/span> <span class=\"kr\">string<\/span><span class=\"p\">;<\/span>\r\n    <span class=\"nl\">type<\/span><span class=\"p\">:<\/span> <span class=\"kr\">string<\/span><span class=\"p\">;<\/span>\r\n    <span class=\"nl\">name<\/span><span class=\"p\">:<\/span> <span class=\"kr\">string<\/span><span class=\"p\">;<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>\u9996\u5148\u4eceAngular1\u7684HTTP\u5f00\u59cb\u3002\u4f7f\u7528\u719f\u6089\u7684$http\u670d\u52a1\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c1\">\/\/\/ &lt;reference path=\"..\/typings\/angularjs\/angular.d.ts\" \/&gt;<\/span>\r\n\r\n<span class=\"kd\">class<\/span> <span class=\"nx\">AppCtrl<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"nl\">pet<\/span><span class=\"p\">:<\/span> <span class=\"nx\">IPet<\/span><span class=\"p\">;<\/span>\r\n    <span class=\"kd\">constructor<\/span><span class=\"p\">(<\/span><span class=\"k\">private<\/span> <span class=\"nx\">$http<\/span><span class=\"p\">:<\/span> <span class=\"nx\">ng<\/span><span class=\"p\">.<\/span><span class=\"nx\">IHttpService<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\r\n        <span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"nx\">$http<\/span><span class=\"p\">.<\/span><span class=\"kd\">get<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">\/api\/v1\/pets\/001.json<\/span><span class=\"dl\">'<\/span><span class=\"p\">)<\/span>\r\n        <span class=\"p\">.<\/span><span class=\"nx\">then<\/span><span class=\"p\">(<\/span><span class=\"nx\">resposnse<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"nx\">response<\/span><span class=\"p\">.<\/span><span class=\"nx\">data<\/span> <span class=\"k\">as<\/span> <span class=\"nx\">IPet<\/span><span class=\"p\">)<\/span>\r\n        <span class=\"p\">.<\/span><span class=\"nx\">then<\/span><span class=\"p\">(<\/span><span class=\"nx\">pet<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\r\n            <span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"nx\">pet<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">pet<\/span><span class=\"p\">;<\/span>\r\n            <span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span><span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"nx\">pet<\/span><span class=\"p\">);<\/span>\r\n            <span class=\"c1\">\/\/ :<\/span>\r\n        <span class=\"p\">});<\/span>\r\n    <span class=\"p\">}<\/span>\r\n<span class=\"p\">}<\/span>\r\n<span class=\"nx\">angular<\/span><span class=\"p\">.<\/span><span class=\"kr\">module<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">app<\/span><span class=\"dl\">'<\/span><span class=\"p\">).<\/span><span class=\"nx\">controller<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">AppCtrl<\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span> <span class=\"nx\">AppCtrl<\/span><span class=\"p\">);<\/span>\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u662f\u9488\u5bf9Angular2\u7684\u60c5\u51b5\u3002\u6211\u4eec\u5c06\u4f7f\u7528angular2\/http\u6a21\u5757\u4e2d\u5305\u542b\u7684Http\u670d\u52a1\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">import<\/span> <span class=\"p\">{<\/span><span class=\"nx\">Component<\/span><span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">angular2\/angular2<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\r\n<span class=\"k\">import<\/span> <span class=\"p\">{<\/span><span class=\"nx\">Http<\/span><span class=\"p\">,<\/span> <span class=\"nx\">HTTP_PROVIDERS<\/span><span class=\"p\">,<\/span> <span class=\"nx\">Response<\/span><span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">angular2\/http<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\r\n\r\n<span class=\"p\">@<\/span><span class=\"nd\">Component<\/span><span class=\"p\">({<\/span>\r\n    <span class=\"na\">selector<\/span><span class=\"p\">:<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">ngcli-sample01-app<\/span><span class=\"dl\">'<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"na\">providers<\/span><span class=\"p\">:<\/span> <span class=\"p\">[<\/span><span class=\"nx\">HTTP_PROVIDERS<\/span><span class=\"p\">],<\/span>\r\n    <span class=\"na\">templateUrl<\/span><span class=\"p\">:<\/span> <span class=\"p\">...<\/span>\r\n<span class=\"p\">})<\/span>\r\n<span class=\"k\">export<\/span> <span class=\"kd\">class<\/span> <span class=\"nx\">MyApp<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"nl\">pet<\/span><span class=\"p\">:<\/span> <span class=\"nx\">IPet<\/span><span class=\"p\">;<\/span>\r\n    <span class=\"kd\">constructor<\/span><span class=\"p\">(<\/span><span class=\"k\">private<\/span> <span class=\"nx\">http<\/span><span class=\"p\">:<\/span> <span class=\"nx\">Http<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\r\n        <span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"nx\">http<\/span><span class=\"p\">.<\/span><span class=\"kd\">get<\/span><span class=\"p\">(<\/span><span class=\"dl\">'<\/span><span class=\"s1\">\/api\/v1\/pets\/001.json<\/span><span class=\"dl\">'<\/span><span class=\"p\">)<\/span>\r\n        <span class=\"p\">.<\/span><span class=\"nx\">map<\/span><span class=\"p\">((<\/span><span class=\"nx\">response<\/span><span class=\"p\">:<\/span> <span class=\"nx\">Response<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"nx\">response<\/span><span class=\"p\">.<\/span><span class=\"nx\">json<\/span><span class=\"p\">()<\/span> <span class=\"k\">as<\/span> <span class=\"nx\">IPet<\/span><span class=\"p\">)<\/span>\r\n        <span class=\"p\">.<\/span><span class=\"nx\">subscribe<\/span><span class=\"p\">(<\/span><span class=\"nx\">pet<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\r\n            <span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"nx\">pet<\/span> <span class=\"o\">=<\/span> <span class=\"nx\">pet<\/span><span class=\"p\">;<\/span>\r\n            <span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span><span class=\"k\">this<\/span><span class=\"p\">.<\/span><span class=\"nx\">pet<\/span><span class=\"p\">)<\/span>\r\n            <span class=\"c1\">\/\/ :<\/span>\r\n        <span class=\"p\">});<\/span>\r\n    <span class=\"p\">}<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>\u6bcf\u4e2aget\u65b9\u6cd5\u90fd\u6ce8\u518c\u4e86\u4ee5\u4e0b\u4e24\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u8fd9\u79cd\u7ed3\u6784\u662f\u76f8\u540c\u7684\u3002 \uff08\u8bf7\u539f\u8c05\uff0c\u8fd9\u53ea\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5173\u4e8e\u201c\u901a\u5e38\u5e94\u8be5\u521b\u5efa\u670d\u52a1\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u4ece\u7ec4\u4ef6\u8c03\u7528HTTP\u201d\u7684\u8bc4\u8bba\uff09<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">HTTP Response \u304b\u3089body\u90e8\u304b\u3089JSON(IPet)\u3092\u53d6\u308a\u51fa\u3059<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u53d7\u3051\u3068\u3063\u305fIPet\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30b4\u30cb\u30e7\u30b4\u30cb\u30e7\u3059\u308b(\u5927\u6982\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30e1\u30f3\u30d0\u5909\u6570\u306b\u4ee3\u5165\u3055\u308c\u305f\u308a\u3059\u308b)<\/ul>\n<p>\u5728\u4f7f\u7528HTTP\u670d\u52a1\u4e4b\u524d\uff0c\u5bfc\u5165\u6a21\u5757\u548c\u4f7f\u7528\u88c5\u9970\u5668\u7b49\u51c6\u5907\u5de5\u4f5c\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff0c\u4f46\u662f\u5728\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e2d\uff0c\u4ee5\u4e0b\u662f\u4e3b\u8981\u7684\u533a\u522b\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Angular1\u306e\u5834\u5408\u3001 .then(&#8230;) \u3067\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u767b\u9332<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Angular2\u306e\u5834\u5408\u3001 .map(&#8230;) \u3068 .subscribe(&#8230;) \u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u767b\u9332<\/ul>\n<p>\u5728\u6c1b\u56f4\u4e2d\uff0c.map\u662f\u4ece\u54cd\u5e94\u4e2d\u63d0\u53d6\u5bf9\u8c61\u7684\u8fc7\u7a0b\uff0c\u800c.subscribe\u5219\u7c7b\u4f3c\u4e8e\u6ce8\u518c\u76d1\u542c\u5668\uff0c\u8fd9\u4e00\u70b9\u6211\u660e\u767d\u4e86\u3002\u4f46\u5728\u6211\u9996\u6b21\u63a5\u89e6Angular2\u7684Http\u670d\u52a1\u65f6\uff0c\u6211\u60f3\u5230\u7684\u662f\uff1a\u201c\u4e3a\u4ec0\u4e48\u4e0d\u518d\u7528then(&#8230;)\u4e86\uff1fmap\u548csubscribe\u662f\u4e9b\u4ec0\u4e48\u4e1c\u897f\uff1f\u201d<\/p>\n<h2>\u627f\u8bfa\u8fd8\u662f\u53ef\u89c2\u5bdf\u6027\uff0c\u8fd9\u662f\u4e2a\u95ee\u9898\u3002<\/h2>\n<p>\u5728Angular1\u4e2d\u4f7f\u7528$http\u670d\u52a1\u6267\u884cAjax\u540e\uff0c\u8fd4\u56de\u7684\u7ed3\u679c\u90fd\u662f\u4e00\u4e2a\u7c7b\u578b\u4e3ang.IPromise\u7684\u8fd4\u56de\u503c\u3002\u5b9e\u9645\u4e0a\uff0c\u5b83\u662f\u901a\u8fc7$q\u670d\u52a1\u751f\u6210\u7684\uff0c\u4f46\u53ef\u4ee5\u50cfES6\u4e2d\u89c4\u8303\u5316\u7684Promise\u4e00\u6837\u4f7f\u7528\u3002<\/p>\n<p>Angular2\u7684Http\u670d\u52a1\u8fd4\u56de\u7684\u4e0d\u662fPromise\uff0c\u800c\u662fObservable\u7c7b\u3002<br \/>\nObservable\u7c7b\u5305\u542b\u5728\u6838\u5fc3\u6a21\u5757angular2\/angular2\u4e2d\uff0c\u800c\u4e0d\u662fangular2\/http\u6a21\u5757\u4e2d\u3002<\/p>\n<p>\u67e5\u770b\u8be5\u5b9a\u4e49\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u51fa Angular2 \u5e76\u975e\u81ea\u5df1\u5b9a\u4e49\u7684\uff0c\u800c\u662f ReactiveX\/RxJS\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">export<\/span> <span class=\"kr\">declare<\/span> <span class=\"kd\">class<\/span> <span class=\"nx\">Observable<\/span><span class=\"o\">&lt;<\/span><span class=\"nx\">T<\/span><span class=\"o\">&gt;<\/span> <span class=\"kd\">extends<\/span> <span class=\"nx\">RxObservable<\/span><span class=\"o\">&lt;<\/span><span class=\"nx\">T<\/span><span class=\"o\">&gt;<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"nx\">lift<\/span><span class=\"o\">&lt;<\/span><span class=\"nx\">T<\/span><span class=\"p\">,<\/span> <span class=\"nx\">R<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">(<\/span><span class=\"na\">operator<\/span><span class=\"p\">:<\/span> <span class=\"nx\">Operator<\/span><span class=\"o\">&lt;<\/span><span class=\"nx\">T<\/span><span class=\"p\">,<\/span> <span class=\"nx\">R<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">):<\/span> <span class=\"nx\">Observable<\/span><span class=\"o\">&lt;<\/span><span class=\"nx\">T<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">;<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"k\">import<\/span> <span class=\"p\">{<\/span> <span class=\"nx\">Subject<\/span><span class=\"p\">,<\/span> <span class=\"nx\">Observable<\/span> <span class=\"k\">as<\/span> <span class=\"nx\">RxObservable<\/span> <span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">'<\/span><span class=\"s1\">@reactivex\/rxjs\/dist\/cjs\/Rx<\/span><span class=\"dl\">'<\/span><span class=\"p\">;<\/span>\r\n<\/code><\/pre>\n<p>\u4e00\u65e6\u5230\u8fd9\u4e2a\u5730\u6b65\uff0c\u5df2\u7ecf\u4e0d\u518d\u53ea\u662f\u5173\u4e8eHTTP\u6216Ajax\u7684\u8ba8\u8bba\uff0c\u800c\u662f\u6d89\u53ca\u5230\u6240\u6709\u5f02\u6b65\u5904\u7406\u7684\u8bdd\u9898\u4e86\u3002<\/p>\n<p>\u7ec8\u4e8e\u628a\u672c\u7bc7\u6587\u7ae0\u7684\u6807\u9898\u62ff\u51fa\u6765\u4e86\u3002<br \/>\n\u5bf9\u4e8e\u6211\u6700\u521d\u7684\u7591\u95ee\u201c\u4e3a\u4ec0\u4e48http.get\uff08&#8230;\uff09.then\u6d88\u5931\u4e86\uff1f\u201d\u4e5f\u5c31\u662f\u201c\u4e3a\u4ec0\u4e48Angular2\u5c06$q\u5220\u9664\u4e86\uff1f\u201d\u7684\u7b54\u6848\uff08\u867d\u7136\u80a4\u6d45\uff09\u53ef\u4ee5\u8bf4\u662f\u201c\u56e0\u4e3a\u8f6c\u5411\u4e86ReactiveX\/RxJS\u800c\u4e0d\u518d\u4f7f\u7528Promise\u201d\u3002<\/p>\n<p>\u7136\u800c\uff0c\u9019\u4e0d\u662f\u4e00\u500b\u7b54\u6848\u3002<br \/>\n\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u5728Angular2\u4ee3\u78bc\u4e2d\u63d0\u5230\u7684 .map, .subscribe \u7684\u4f7f\u7528\u65b9\u6cd5\u4ee5\u53caObservable\u7684\u5176\u4ed6\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u95b1\u8b80ReactiveX \/ RxJS\u6216\u5176\u6e90\u982d\u7684RxJS\u4e3b\u6a21\u7d44\u53c3\u8003\u4f86\u7406\u89e3\u3002<br \/>\n\uff08\u6b63\u5982@ armorik83\u6240\u6307\u51fa\u7684\uff0cRxJS\u5b58\u5728\u5169\u500b\u7cfb\u7d71\u3002Angular2\u4f7f\u7528\u5e36\u6709@ReactiveX\u7684\u90a3\u4e00\u500b\u3002\uff09<\/p>\n<p>\u6211\u771f\u6b63\u60f3\u8981\u7406\u89e3\u7684\u662f\u4e3a\u4ec0\u4e48\u9009\u62e9\u6539\u53d8Angular2\uff0c\u5373\u5176\u539f\u56e0\u3002<\/p>\n<p>\u4f5c\u4e3a\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\u7684\u4e00\u4e2a\u7b54\u6848\uff0c\u57282015\u5e7410\u6708\u7684Angular Connect\u4f1a\u8bae\u4e0a\uff0cBen Lesh\u8fdb\u884c\u4e86\u6709\u5173RxJS\u7684\u6df1\u5ea6\u8bb2\u89e3\uff0c\u4ed6\u63d0\u5230\u4e86Observable\u4f18\u4e8ePromise\u7684\u65b9\u9762\uff08\u5efa\u8bae\u4ece5\u520648\u79d2\u5f00\u59cb\u89c2\u770b\uff09\u3002<\/p>\n<p>\u7b80\u5355\u6765\u8bf4\uff0c\u8bf4\u660e\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>\u5728\u73b0\u4ee3Web\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u5e94\u8be5\u5904\u7406\u4ee5\u4e0b\u5f02\u6b65\u5904\u7406\uff1a<\/p>\n<p>DOM\u4e8b\u4ef6\uff080-N\u4e2a\u503c\uff09<br \/>\n\u52a8\u753b\uff08\u53ef\u53d6\u6d88\uff09<br \/>\nAjax\uff081\u4e2a\u503c\uff09<br \/>\nWebSockets\uff080-N\u4e2a\u503c\uff09<br \/>\n\u670d\u52a1\u5668\u7aef\u4e8b\u4ef6\uff080-N\u4e2a\u503c\uff09<\/p>\n<p>\u4e0ePromise\u7684\u7279\u70b9\uff08\u8fd9\u79cd\u7b80\u5355\u7684\u7279\u70b9\u4e5f\u53ef\u4ee5\u8bf4\u662fPromise\u7684\u4f18\u70b9\uff09\u76f8\u5bf9\u6bd4\uff0c\u53ef\u4ee5\u5f97\u51fa\u4ee5\u4e0b\u7ed3\u8bba\uff1a<\/p>\n<p>\u786e\u4fdd\u8981\u4e48\u6210\u529f\u8981\u4e48\u5931\u8d25\u3002\u4e00\u65e6\u751f\u6210\u4e86Promise\uff0c\u5c31\u4e0d\u4f1a\u88ab\u53d6\u6d88\u3002<br \/>\n\u4e00\u65e6\u51b3\u5b9a\u4e86\u6210\u529f\u6216\u5931\u8d25\u7684\u7ed3\u679c\uff0c\u5c31\u662f\u4e0d\u53d8\u7684\u3002<\/p>\n<p>\u5728\u4e0a\u8ff0\u63d0\u5230\u7684\u5f02\u6b65\u5904\u7406\u4e2d\uff0c\u53ea\u6709Ajax\u53ef\u4ee5\u7531Promise\u6765\u89e3\u51b3\u3002<br \/>\n\u800c\u53ef\u4ee5\u5c06\u53d1\u751f\u7684\u4e8b\u4ef6\u89c6\u4e3a\u6d41\u6765\u5904\u7406\u7684Observable\u53ef\u4ee5\u9002\u7528\u4e8e\u5148\u524d\u63d0\u5230\u7684\u4efb\u4f55\u5f02\u6b65\u5904\u7406\u3002<\/p><\/blockquote>\n<p>\u770b\u8d77\u6765 RxJS \u7684\u5f00\u53d1\u8005\u5bf9 Promise \u7684\u8bc4\u4ef7\u597d\u50cf\u4e0d\u592a\u597d&#8230;<br \/>\n\u65e0\u8bba\u662f Promise \u8fd8\u662f Observable\uff0c\u5b83\u4eec\u90fd\u53ef\u4ee5\u6210\u4e3a\u5e2e\u52a9\u5f00\u53d1\u8005\u6446\u8131\u56de\u8c03\u5730\u72f1\u7684\u624b\u6bb5\uff0c\u4f46\u662f\u4e8b\u5b9e\u4e0a\u5b83\u4eec\u5404\u81ea\u90fd\u6709\u957f\u77ed\u4e4b\u5904\u3002<\/p>\n<p>\u627f\u8bfa\u662f\u4e00\u79cd\u540d\u4e3aFuture\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5176\u6839\u672c\u76ee\u7684\u662f\u62bd\u8c61\u5316&#8221;\u8c03\u7528\u5904\u7406 -&gt; (\u5fc5\u8981\u65f6\u7b49\u5f85) -&gt; \u63a5\u6536\u7ed3\u679c\u5e76\u7ee7\u7eed\u4e0b\u4e00\u4e2a\u5904\u7406&#8221;\u7684\u8fc7\u7a0b\u3002<br \/>\n\u6b63\u56e0\u4e3a\u5982\u6b64\uff0c\u50cf\u6700\u8fd1\u4eceTypeScript 1.7\u5f00\u59cb\u53ef\u7528\u7684Async\/Await\u8fd9\u6837\u7684\u8bb0\u6cd5\u5f88\u9002\u5408\u7f16\u5199\u5305\u542b\u4e32\u884c\u5f02\u6b65\u4ee3\u7801\u7684\u5f62\u5f0f\u3002<br \/>\n\u5982\u679c\u6709\u4eba\u8bf4&#8221;Promise\u53ef\u80fd\u4f1a\u88ab\u591a\u6b21\u89e3\u6790\uff0c\u6240\u4ee5\u65e0\u6cd5\u786e\u5b9athen\u4e2d\u6ce8\u518c\u7684\u56de\u8c03\u4f1a\u6267\u884c\u591a\u5c11\u6b21&#8221;\u6216\u8005&#8221;Promise\u5df2\u88ab\u53d6\u6d88&#8221;\u4e4b\u7c7b\u7684\u8bdd\uff0c\u6211\u6839\u672c\u65e0\u6cd5\u60f3\u8c61\u5982\u4f55\u80fd\u5199\u51fa\u7c7b\u4f3cAsync\/Await\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u4e00\u65b9\uff0cObservable\u662f\u6e90\u5934\u7684\u53d1\u5e03\u8005\/\u8ba2\u9605\u8005\u6a21\u578b\u3002<br \/>\n\u8fd9\u4e00\u6a21\u578b\u7684\u6700\u5927\u7279\u70b9\u662f\u901a\u8fc7\u201c\u5c06\u4e8b\u4ef6\u53d1\u751f\u7684\u6e90\u5934(\u53d1\u5e03\u8005)\u548c\u76d1\u542c\u8005(\u8ba2\u9605\u8005)\u5206\u79bb\u6765\u5b9e\u73b0\u677e\u8026\u5408\u6027\u201d\u3002 Observable\u76f8\u5f53\u4e8e\u8ba2\u9605\u8005\uff0c\u65e0\u8bba\u4e8b\u4ef6\u7684\u53d1\u751f\u6e90\u662fHttp.get(url)\u8fd8\u662f\u5176\u4ed6\u4ec0\u4e48\uff0c\u5b83\u5bf9\u6b64\u4e00\u65e0\u6240\u77e5\u3002<br \/>\n\u6b63\u662f\u8fd9\u79cd\u677e\u8026\u5408\u6027\uff0c\u6210\u4e3a\u5904\u7406\u5404\u79cd\u4e8b\u4ef6\u6e90\u7684\u52a8\u529b\u3002<\/p>\n<h2>Angular = {1: &#8220;\u53cc\u5411&#8221;, 2: &#8220;\u5355\u5411&#8221;};<\/h2>\n<p>\u6700\u540e\uff0c\u6211\u60f3\u8003\u8651\u4e00\u4e0bAngular1\u548cAngular2\u5728\u6570\u636e\u7ed1\u5b9a\u601d\u60f3\u65b9\u9762\u7684\u5dee\u5f02\u4e0e\u5f02\u6b65\u5b9e\u73b0\u7684\u5173\u7cfb\u3002<\/p>\n<p>\u6839\u636e @shinsukeimai \u5148\u751f\u5728\u4e00\u6628\u65e5\u7684Advent Calendar \u4e0a\u7684\u8bf4\u6cd5\uff0cAngular2\u4e2d\u7684\u6570\u636e\u7ed1\u5b9a\u65b9\u5f0f\u53d8\u5f97\u66f4\u52a0\u7075\u6d3b\u3002<br \/>\n\u4e0eAngular1\u6700\u5927\u7684\u7279\u70b9\u2014\u2014\u53cc\u5411\u6570\u636e\u7ed1\u5b9a\u4e0d\u540c\uff0c\u73b0\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u91c7\u7528\u4e86 [\u89c6\u56fe -&gt; \u7ec4\u4ef6] \u548c [\u7ec4\u4ef6 -&gt; \u89c6\u56fe] \u8fd9\u4e24\u79cd\u5355\u5411\u7ed1\u5b9a\u7684\u7ec4\u5408\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u5173\u4e8eObservable\uff08Angular2\uff09\uff0c\u5c31\u50cf\u4e4b\u524d\u63d0\u5230\u7684\u90a3\u6837\uff0c\u201c\u5f02\u6b65\u5904\u7406\u7684\u53d1\u751f\u6e90\u201d\u548c\u201c\u7ed3\u679c\u5904\u7406\u201d\u662f\u72ec\u7acb\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u7528\u4e4b\u524d\u7684\u7c7b\u6bd4\u6765\u7406\u89e3\uff0c\u5b83\u6709\u4e24\u4e2a\u5355\u5411\u5b58\u5728\uff0c\u5373[\u67d0\u4e2a -&gt; \u5f02\u6b65\u53d1\u751f]\u548c[\u67d0\u79cd\u7ed3\u679c -&gt; \u540e\u7eed\u5904\u7406]\u3002<\/p>\n<p>\u5230\u4e86\u8fd9\u4e00\u6b65\uff0c\u5b83\u53d8\u6210\u4e86\u4e00\u4e2a\u542c\u8fc7\u7684\u6545\u4e8b\u3002 \u662f\u7684\uff0c\u5c31\u662f\u90a3\u4e2a\u5728Flux\u548cRedux\u4e2d\u88ab\u79f0\u4e3a\u201c\u4e00\u5207\u90fd\u662f\u5355\u5411\u5904\u7406\u201d\u7684\u4e1c\u897f\u3002<br \/>\n\u4ecePromise\u5230Observable\u7684\u8f6c\u53d8\u4f3c\u4e4e\u4e5f\u53ef\u4ee5\u4ee5\u5355\u5411\u5904\u7406\u4e3a\u4e2d\u5fc3\u3002<\/p>\n<p>\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0c\u53cc\u5411\u7ed1\u5b9a\u771f\u7684\u662f\u4e00\u4ef6\u574f\u4e8b\u5417\uff1f<br \/>\n\u5728Angular1\u4e2d\uff0c\u53cc\u5411\u6570\u636e\u7ed1\u5b9a\u548cPromise\u7684&#8221;[\u8c03\u7528 &lt;-&gt; \u5904\u7406\u7ed3\u679c]\u7684\u7ec4\u5408&#8221;\u786e\u5b9e\u53ef\u80fd\u65e0\u6cd5\u89e3\u51b3\u50cfWeb Socket\u90a3\u6837\u7684\u60c5\u51b5\uff0c\u6b63\u5982Ben Lesh\u6240\u8bf4\u3002<br \/>\n\u4f46\u662f\uff0c\u901a\u8fc7\u9075\u5faa\u201c\u5c06\u8f93\u5165\u548c\u8f93\u51fa\u59cb\u7ec8\u4f5c\u4e3a\u4e00\u7ec4\u5904\u7406\u201d\u8fd9\u4e2a\u9650\u5236\u6765\u7f16\u5199\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u76f8\u5f53\u6e05\u6670\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u5355\u5411\u5904\u7406\u548c\u4e8b\u4ef6\u4e0e\u76d1\u542c\u5668\u7684\u677e\u6563\u8026\u5408\u6027\u4f7f\u5f97\u5355\u72ec\u7684\u7ec4\u4ef6\u53ef\u6d4b\u8bd5\u6027\u8f83\u9ad8\uff0c\u4f46\u4e5f\u5305\u542b\u4e86\u5bb9\u6613\u9677\u5165\u201c\u4e0d\u77e5\u9053\u5728\u54ea\u91cc\u4f1a\u53d1\u751f\u4ec0\u4e48\u201d\u60c5\u51b5\u7684\u98ce\u9669\u3002<br \/>\nFlux\u548cRedux\u901a\u8fc7\u5c06\u201c\u4f55\u65f6\u4f55\u5730\u53d1\u751f\u4f55\u4e8b\u201d\u7eb3\u5165\u6307\u5357\uff0c\u8bd5\u56fe\u907f\u514d\u8fd9\u79cd\u98ce\u9669\u3002<\/p>\n<h2>\u6700\u540e\u4e00\u53e5<\/h2>\n<p>\u5373\u4f7f$q\u5df2\u7ecf\u88ab\u5220\u9664\uff0c\u4f46\u7531\u4e8eObservable\u4e2d\u5b58\u5728\u8bf8\u5982toPromise(&#8230;)\u7b49\u8f6c\u6362\u5de5\u5177\uff0c\u6240\u4ee5\u6211\u8ba4\u4e3a\u5728Angular2\u4e2d\u4e5f\u6709\u53ef\u80fd\u57fa\u4e8ePromise\u6765\u5904\u7406\u5f02\u6b65\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5c31\u50cf\u5728Angular1\u4e2d\u4e00\u6837\u3002<\/p>\n<p>\u5728Angular2\u4e2d\u53ef\u4ee5\u4f7f\u7528RxJS\u7684\u4e30\u5bcc\u529f\u80fd\u786e\u5b9e\u4ee4\u4eba\u9ad8\u5174\uff0c\u4f46\u540c\u65f6\u4e5f\u611f\u89c9\u5230\u5728\u8bbe\u8ba1\u65f6\u9700\u8981\u66f4\u52a0\u8c28\u614e\u3002\u5c3d\u7ba1\u6211\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u5bf9RxJS\u548cFRP\u7684\u8303\u5f0f\u90fd\u6ca1\u6709\u5b9e\u8df5\u548c\u8bbe\u8ba1\u7ecf\u9a8c\uff0c\u4f46\u6211\u89c9\u5f97\u901a\u8fc7Angular2\u6765\u9762\u5bf9\u5b83\u4eec\u4e5f\u662f\u5f88\u6709\u8da3\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u4eca\u5929\u7684\u8bdd\u9898\u51e0\u4e4e\u6ca1\u6709\u6d89\u53ca\u5230\u5b9e\u65bd\uff0c\u4f46\u662f\u6211\u5e0c\u671b\u5c06\u6765\u65e2\u8981\u5728Angular2\u4e0a\u5c1d\u8bd5\u8bbe\u8ba1\u548c\u5b9e\u65bd\u53cc\u91cd\u9762\u4e5f\u8981\u518d\u6b21\u8c08\u8bba\u8fd9\u4e2a\u4e3b\u9898\u3002<\/p>\n<p>\u660e\u5929\u662f @yuhiisk \u5148\u751f\u3002<\/p>\n<h2>\u8bf7\u5728\u4e2d\u56fd\u672c\u5730\u8bed\u8a00\u4e2d\u8fdb\u884c\u6392\u5217\u987a\u5e8f<\/h2>\n<p>Angular2 Observables, Http, and separating services and components : Angular2 Http\u306e\u4f7f\u3044\u65b9\u304c\u3088\u308a\u8a73\u7d30\u306b\u7d39\u4ecb\u3055\u308c\u3066\u307e\u3059<\/p>\n<p>\u3010\u7ffb\u8a33\u3011\u3042\u306a\u305f\u304c\u6c42\u3081\u3066\u3044\u305f\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5165\u9580 : \u7a0b\u3088\u3044\u7c92\u5ea6\u3067Reactive\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u304f\u308c\u3066\u308b<\/p>\n<p>\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u7d39\u4ecb -GoF\u4ee5\u5916\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u7d39\u4ecb\u3057\u307e\u3059- : \u305d\u3082\u305d\u3082Future\u30d1\u30bf\u30fc\u30f3\u3063\u3066\u4f55\u3060\u3063\u3051\uff1f\u3063\u3066\u8a71\u3092\u7d50\u57ce\u5148\u751f\u304c\u89e3\u8aac\u3057\u3066\u304f\u308c\u3066\u308b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u6211\u662f@Quramy\uff0c\u5bf9\u4e8eAngular1\uff0c\u6211\u6709\u4e00\u5b9a\u7684\u4e86\u89e3\uff0c\u4f46\u662f\u8fd9\u662f\u6211\u7b2c\u4e00\u6b21\u8ba8\u8bbaAngular2\uff0c\u611f\u89c9\u50cf\u4e2a [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-38903","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u601d\u8003angular1\u548cangular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u6211\u662f@Quramy\uff0c\u5bf9\u4e8eAngular1\uff0c\u6211\u6709\u4e00\u5b9a\u7684\u4e86\u89e3\uff0c\u4f46\u662f\u8fd9\u662f\u6211\u7b2c\u4e00\u6b21\u8ba8\u8bbaAngular2\uff0c\u611f\u89c9\u50cf\u4e2a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u601d\u8003angular1\u548cangular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-21T23:06:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T22:25:57+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u96c5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u96c5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/\",\"name\":\"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-06-21T23:06:40+00:00\",\"dateModified\":\"2024-04-29T22:25:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\",\"name\":\"\u79d1, \u96c5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u96c5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u601d\u8003angular1\u548cangular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904","og_description":"\u9996\u5148 \u6211\u662f@Quramy\uff0c\u5bf9\u4e8eAngular1\uff0c\u6211\u6709\u4e00\u5b9a\u7684\u4e86\u89e3\uff0c\u4f46\u662f\u8fd9\u662f\u6211\u7b2c\u4e00\u6b21\u8ba8\u8bbaAngular2\uff0c\u611f\u89c9\u50cf\u4e2a [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u601d\u8003angular1\u548cangular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-06-21T23:06:40+00:00","article_modified_time":"2024-04-29T22:25:57+00:00","author":"\u79d1, \u96c5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u96c5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/","name":"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-06-21T23:06:40+00:00","dateModified":"2024-04-29T22:25:57+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u601d\u8003Angular1\u548cAngular2\u7684\u5f02\u6b65\u5904\u7406\u7684\u4e0d\u540c\u4e4b\u5904"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a","name":"\u79d1, \u96c5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","caption":"\u79d1, \u96c5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%80%9d%e8%80%83angular1%e5%92%8cangular2%e7%9a%84%e5%bc%82%e6%ad%a5%e5%a4%84%e7%90%86%e7%9a%84%e4%b8%8d%e5%90%8c%e4%b9%8b%e5%a4%84%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/38903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=38903"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/38903\/revisions"}],"predecessor-version":[{"id":90246,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/38903\/revisions\/90246"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=38903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=38903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=38903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}