`

eclipse中如何使用angularjs的提示功能

阅读更多

Getting Started

This page explains how to install and configure AngularJS Eclipse. This Eclipse plugin is based on the powerful javascript inference engine tern.js which is written in javascript. To use this engine on Java context, tern.java is used. It executes tern.js with node.js. That's why you will see that, you must install node.js server or use an embed node.js.

If you don't install node.js or don't use an embed node.js, only syntax coloring and completions directives will be available in HTML editor.

Installation

AngularJS Eclipse is developed/tested with Eclipse 4.4 (Luna). It is advised to use Luna (even if AngularJS Eclipse could work with older version of Eclipse).

To install AngularJS Eclipse, please read Installation - Update Site section.

When you will use AngularJS Eclipse update site you will see that:

Update site

You must select:

  • AngularJS Eclipse Tooling which is AngularJS Eclipse plugins .
  • AngularJS support for JSP if you wish to use JSP with AngularJS.
  • Tern - Embed Node.js if you have not node.js installed on your computer. Node.js is required to execute tern.js.
  • Tern IDE to use tern with Eclipse IDE.
  • Tern - Tooling if you want to generate tern plugin, JSON Type Definition or Web Browser editor (CodeMirror, Ace, Orion) with tern. For more information please read Tern Toolings

AngularJS Configuration

Before using AngularJS Eclipse features (HTML features and JavaScript features) you must convert your project to AngularJS Project :

Convert To AngularJS Project

Preferences Settings

This section explains how to configure tern and angular.

Global Preferences

This section is about "global preferences" dialog that you open with Window/Preferences.

Node.js

AngularJS Eclipse is based on the javascript inference engine tern.js is written in JavaScript. To use it, tern is executed with node.js (Rhino is too slow for that). You must configure node.js. To do that you can :

  • use your installed node.js. For that, you must select the "Native node" install type and select the well node file :

Native Node

when the native node is selected, it searches node binary in default folders installation (ex : "C:\Program Files\nodejs\node.exe" for Windows) and if it doesn't find, it searches in your node in your "PATH" environment.

If you wish to download and install node.js, it's important to restart your computer before using AngularJS Eclipse in order to your OS update correctly your "PATH" environment with your installed node.js.

  • use an embed node. For that you must install the well embed node.js according your OS :

Embed Node

Project preferences

This section is about "project properties" dialog which is available if you select your project and use "Properties" menu item of the contextual menu (or Alt/Enter).

Tern Modules

Tern module is a Tern Plugin or JSON Type definition. Check that angular plugin is checked :

Tern Plugin.

The angular plugin gives you the capability to retrieve module, controllers,(custom) directives, etc from your javascript, manages completion hyperlink, hover, validation in HTML and JavaScript editor. It's enable to emulate the angular injection on your $scope, $http, etc.

You can select other tern module like jQuery for instance to benefit with jQuery completion inside JavaScript Editor.

Scripts path

When tern is used for completion, validation, hover, hyperlink, it must load before (just the first time) a list of your JavaScript. To do that you must configure your script paths by selecting your js folder which contains your javascripts (it's the same thing than for Java build path) :

Script paths

For more information, please read Tern Script Path

Customize Directives syntax

In HTML editor, directives completion provides directive names with the ng-* syntax :

HTMLAngularConfigureDirective1

Angular supports several syntax like starting with 'x-', 'data-' and use ':', '-', '_' delimiters. You can customize the syntax that you wish for completion with the project properties. By default you will see this configuration :

HTMLAngularConfigureDirective2

You can select other starts with and delimiters. You can see in the textarea the directive names that completion will show :

HTMLAngularConfigureDirective3

After validating your configuration, completion will show you directive names with other syntaxes :

HTMLAngularConfigureDirective3

Validation

If you validate with "Validate" menu contextual menu :

HTMLAngularValidatorValidate

you will see that AngularJS directives will have warn messages :

HTMLAngularValidatorWarnDirective

In this sample you have 2 warnings messages :

  • a warning with ng-app which is an Angular directive
  • a warning with "a" attribute in the head element which doesn't exist.

You could disable the warning message for unknown attribute, but AngularJS Eclipse provides the "HTML Angular Syntax Validator" which is an extension of the "HTML Syntax Validator" to support Angular directives. To use this Angular validator, you must enable it and disable "HTML Syntax Validator" :

HTMLAngularValidatorUseAngular

If you revalidate you will see that directive are not marked as warning and other unknown attributes are marked as warning :

HTMLAngularValidatorWarnUnknownAttr

Validation & JSP

If you use JSP, you must disable JSP Content Validator and enable JSP Angular Content Validator.

Let's go!

At this step we have finished to configure AngularJS Eclipse, now it's time to check that everything works (tern with node.js is well configured).

HTML Editor

Open an HTML file by using standard WTP HTML, JSP editor.

Try completion on ng-app to open your module:

Angular Editor

This feature is managed by tern, if it doesn't work, see Troubleshooting section.

JavaScript Editor

Open a javascript editor and try to open completion for angular model:

Angular Editor

This feature is managed by tern, if it doesn't work, see Troubleshooting section.

Troubleshooting

If you have checked your configuration and completion doesn't work for HTML and JavaScript editor, it means that there is a problem with tern with node.js. To verify that you can see errors with :

  • Error log view.
  • Tern console

Error log view

TernErrorLog

Tern console

You can trace the start of node.js server and the request/response of the tern server by using the Eclipse console.

To do that, you must active the tern console for your project:

TernConsoleProjectProperties

and open the tern console:

TernConsoleOpen

If you retry to execute completion for instance to use tern server, you will see the node.js command and the error in the console:

TernConsoleError

When you will have not problem, you can see the JSON request/response of the tern server when it is use it:

TernConsoleOK

See Tern Console for more information.

If you have again, problem, please create an issue here.

Angular Explorer

Angular Explorer View gives you the capability to display Angular elements like modules, controllers of your AngularJS application. To open it go to Window/Show View and select Angular Explorer :

ShowViewAngularExplorer

After that you can see your modules, controllers, etc :

Angular Explorer

Please read Angular Explorer for more information.

分享到:
评论

相关推荐

    AngularJS Eclipse 1.2.0 插件下载

    3. **模板语法验证**:AngularJS的HTML模板中使用了大量的指令和表达式,插件可以对这些模板进行语法检查,确保模板的正确性。 4. **调试支持**:插件允许开发者在Eclipse中设置断点,进行单步调试,查看变量值,...

    org.eclipse.angularjs.category-0.9.0.zip

    6. 安装完成后,重启Eclipse,新插件应该就能在JavaScript编辑器中提供AngularJS的智能提示和功能了。 通过这样的插件,开发者可以在Eclipse中获得更流畅的AngularJS开发体验,提高开发效率,减少错误,并且能更好...

    angularjs-eclipse.zip

    这款插件为Eclipse提供了对AngularJS项目的支持,包括代码提示、语法高亮、自动完成、错误检查等功能,极大地提升了开发者的编码体验。特别的是,它还集成了AngularJS的文档,方便开发者查阅API和最佳实践。 当我们...

    eclipse-js代码提示助手

    安装和使用这款插件非常简单,只需要在Eclipse中通过插件市场搜索"eclipse-js代码提示助手",按照指引进行安装,然后在JavaScript编辑器中即可体验到其带来的便捷。值得注意的是,确保Eclipse版本与插件兼容,并保持...

    eclipse 中html,js提示jar包插件.zip

    "jar js、html提示"标签表明这个插件可能包含了处理JavaScript和HTML所需的一些库或者框架的API提示,例如jQuery、AngularJS、Vue.js等,让开发者在使用这些库时也能享受到强大的代码提示功能。 总的来说,"eclipse...

    eclipse-angular-1.2插件.rar

    Eclipse写JS代码时提示功能,离线安装angularJs的eclipse插件。同时包括离线安装插件的步骤。 安装好以后,重启eclipse 选择你的项目,右键你的项目选择Configure convert to AngularJS project 在弹出的Modules中...

    解决eclipse中没有js代码提示的问题

    在JavaScript开发过程中,IDE的代码提示功能至关重要,它能提高编码效率,减少因拼写错误导致的bug。本文主要讨论如何解决在Eclipse IDE中遇到的JavaScript代码提示缺失的问题。 首先,问题描述中提到,用户在使用...

    两个比较好用的Eclipse中javascript插件jsEditor jsEclipse

    安装这两款插件非常简单,只需在Eclipse的“帮助”菜单中选择“Eclipse Marketplace”,然后搜索相应的插件名,按照提示进行安装即可。安装完成后,Eclipse会自动识别.js文件并应用这些插件的功能。 在压缩包...

    Eclipse中实现JS代码提示功能(图文教程)

    然而,Eclipse默认情况下并不提供JS代码提示功能,这给JavaScript开发者带来了一定的不便。本文将详细讲解如何在Eclipse中启用JS代码提示,帮助开发者提高编码效率。 首先,为了实现这一功能,我们需要安装一个专门...

    ionic angularjs mobile ui

    在Eclipse中直接导入 Ionic 和 AngularJS 项目,开发者可以利用其强大的代码编辑、调试和项目管理功能。 6. **项目结构**:下载的压缩包可能包含了一个完整的Ionic项目结构,包括`www`目录(存放应用静态资源)、`...

    Eclipse 中安装Spekt 插件

    在本文中,我们将深入探讨如何在Eclipse集成开发环境中安装并使用Spket插件,这是一种强大的JavaScript和Ajax开发工具。Spket提供了语法高亮、自动完成、代码模板和错误检查等功能,极大地提高了开发者的工作效率。 ...

    Eclipse的JavaScript插件 JSEditor

    Eclipse作为一个强大的开源集成开发环境(IDE),广泛用于Java编程,但...使用Eclipse的JavaScript插件JSEditor,意味着你可以在一个专业且功能全面的环境中编写和调试JavaScript代码,享受到高效且便捷的开发体验。

    Eclipse、MyEclipse开发工具

    代码提示功能则可以根据上下文显示可能的函数、变量和对象,提高编写速度。JSDoc注释生成功能可以帮助编写规范的文档,便于团队协作。此外,Spket还支持代码格式化,保持代码整洁统一。 为了调试JavaScript代码,...

    Eclipse JQuery插件Spket

    Eclipse是一款广泛使用的Java集成开发环境(IDE),但它的功能并不仅限于Java,通过安装各种插件,也可以很好地支持JavaScript和其他Web开发工作。在JavaScript领域,jQuery是一个非常流行的库,它极大地简化了DOM...

    eclipse皮肤和js开发插件

    - **jQuery Integration**:如需在Eclipse中使用jQuery,可安装jQuery插件,以便获得更好的代码提示和语法支持。 - **Node.js Developer Tools**:对于Node.js开发,可以安装Nodeclipse插件,提供项目创建、调试、...

    eclipse的js插件和css插件

    本主题将详细探讨如何在Eclipse中安装和使用JavaScript和CSS插件,以提升前端开发的效率。 首先,让我们关注“JSEclipse_1.5.5.zip”这个文件。JSEclipse是Eclipse中的一个JavaScript插件,它提供了对JavaScript的...

    Spket插件 Eclipse插件

    它是一款专门为Eclipse设计的JavaScript开发插件,极大地提升了在Eclipse中编写、调试和理解JavaScript代码的效率。 **Spket插件的核心功能** 1. **代码补全**:Spket提供强大的代码补全功能,能够自动完成...

    用于myeclipse中js提示的spket插件

    3. **使用技巧**:在编写JavaScript代码时,可以利用Spket的代码提示功能快速输入函数名、变量名、对象属性等,提高编码效率。同时,其语法检查功能可以帮助开发者及时发现并修正错误。 4. **与其他工具的比较**:...

    AngularJS 学习笔记(表单验证篇)

    提供的压缩包文件可能包含一个Eclipse工程,方便开发者在IDE中编辑和运行代码,同时也可以直接在浏览器中查看运行结果,这对于学习和调试AngularJS表单验证功能非常有用。 通过学习和实践这些知识点,你将能够熟练...

Global site tag (gtag.js) - Google Analytics