Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the define function do in AngularJS?

Sometimes I see code that looks like this in Angular:

define(['angular', 'module'], function (angular, module) {
  //...
});

What does this do? Whenever I've tried to search for "angularjs define" or "angularjs define function" I see results like "How to define a function in AngularJS" or "AngularJS Defined."

This happens with search engines, and typing this into the search box on the AngularJS website doesn't help either.

Where is the documentation for this?

like image 989
A. Duff Avatar asked Dec 03 '14 19:12

A. Duff


People also ask

What is define in angular?

Definition of angular 1a : forming an angle : sharp-cornered. b : having one or more angles. 2 : measured by an angle angular distance. 3a : stiff in character or manner : lacking smoothness or grace. b : lean and having prominent bone structure.

Which function is used to create a module in AngularJS?

js. var app = angular. module("myApp", []); The [] parameter in the module definition can be used to define dependent modules.

What is Controlleras in AngularJS?

In AngularJS, a Controller is defined by a JavaScript constructor function that is used to augment the AngularJS Scope. Controllers can be attached to the DOM in different ways.


1 Answers

Its probably because you're assuming its an Angular function. I believe this is RequireJS.

http://requirejs.org/docs/api.html#define

like image 76
Khan Avatar answered Oct 05 '22 05:10

Khan