小编Bud*_*aka的帖子

如何在角度2中使用jQuery和javascript

    import {Component, ElementRef, OnInit} from 'angular2/core';
    declare var jQuery:any;
    @Component({
      selector: 'jquery-integration',
      templateUrl: './components/jquery-integration/jquery-integration.html'
    })
    export class JqueryIntegration implements OnInit {
      elementRef: ElementRef;
      constructor(elementRef: ElementRef) {
        this.elementRef = elementRef;
      }
      ngOnInit() {
        jQuery(this.elementRef.nativeElement).draggable({
        containment:'#draggable-parent'
      });
    }
  }
Run Code Online (Sandbox Code Playgroud)

可以像上面那样在Angular2中使用jQuery与jQuery一起使用吗?如何在Angular2中使用jQuery和JavaScript?

jquery typescript angular

15
推荐指数
3
解决办法
6万
查看次数

未捕获的ReferenceError:在angular2中未定义require

<html>
<head>
<title>Angular 2 QuickStart</title>
<!-- 1. Load libraries -->
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/rxjs/bundles/Rx.umd.js"></script>
<script src="node_modules/angular2/bundles/angular2-all.umd.js"></script>
<!-- 2. Load our 'modules' -->
<script src='app/app.component.js'></script>
<script src='app/boot.js'></script>

<!--upgrade-->
<script src="node_modules/angular2/upgrade.js"></script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

没有<script src="node_modules/angular2/upgrade.js"></script>代码工作正常.当我包括upgrade.js.it显示"未捕获的ReferenceError:require未在angular2中定义".如何克服此错误.

angular2-routing angular

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

angular ×2

angular2-routing ×1

jquery ×1

typescript ×1