Class Angular

java.lang.Object
org.angular.ts.ng.Angular

@JsType(isNative=true, name="ng.Angular", namespace="<global>") public class Angular extends Object
AngularTS runtime instance used to create modules, bootstrap DOM trees, create injectors, and recover scopes from native elements.
  • Field Details

    • ScopeElement

      public ScopeElement<Object> ScopeElement
      Base class for user-authored AngularTS custom elements.
    • currentInjector

      public InjectorService<Object> currentInjector
      Application injector, available after `bootstrap()` or `injector()` completes.
    • eventBus

      public EventBusService eventBus
      Application-wide event bus, available after bootstrap providers are created.
    • rootScope

      public Scope rootScope
      Root scope for the bootstrapped application.
    • subapps

      public elemental2.core.JsArray<Object> subapps
      Sub-application instances created when multiple `ng-app` roots are initialized.
    • tokens

      public Object tokens
      Public injection token names keyed by token value.
    • version

      public String version
      AngularTS version string replaced at build time.
    • view

      public Object view
      Explicit programmatic-view binding and element helpers.
  • Constructor Details

    • Angular

      public Angular()
  • Method Details

    • bootstrap

      public InjectorService<Object> bootstrap(Angular.BootstrapElementUnionType element, elemental2.core.JsArray<Object> modules)
      Use this function to manually start up AngularTS application. AngularTS will detect if it has been loaded into the browser more than once and only allow the first loaded script to be bootstrapped and will report a warning to the browser console for each of the subsequent scripts. This prevents strange results in applications, where otherwise multiple instances of AngularTS try to work on the DOM. **Note:** Do not bootstrap the app on an element with a directive that uses transclusion, such as `ng-if`, `ng-include`, or `ng-view`. Doing this misplaces the app root element and injector, causing animations to stop working and making the injector inaccessible from outside the app. ```html <!doctype html> <html> <body> <div ng-controller="WelcomeController"> {{greeting}} </div> <script src="angular.js"></script> <script> let app = angular.createModule('demo', []) .controller('WelcomeController', ['$scope', function($scope) { $scope.greeting = 'Welcome!'; }]); angular.bootstrap(document, ['demo']); </script> </body> </html> ```
      Parameters:
      element - DOM element which is the root of AngularTS application.
      modules - an array of modules to load into the application. Each item in the array should be the name of a predefined module or a (DI annotated) function that will be invoked by the injector as a `config` block. See `angular.createModule()` and `angular.getModule()`.
      Returns:
      Method result.
    • bootstrap

      @JsOverlay public final InjectorService<Object> bootstrap(Document element, elemental2.core.JsArray<Object> modules)
      Use this function to manually start up AngularTS application. AngularTS will detect if it has been loaded into the browser more than once and only allow the first loaded script to be bootstrapped and will report a warning to the browser console for each of the subsequent scripts. This prevents strange results in applications, where otherwise multiple instances of AngularTS try to work on the DOM. **Note:** Do not bootstrap the app on an element with a directive that uses transclusion, such as `ng-if`, `ng-include`, or `ng-view`. Doing this misplaces the app root element and injector, causing animations to stop working and making the injector inaccessible from outside the app. ```html <!doctype html> <html> <body> <div ng-controller="WelcomeController"> {{greeting}} </div> <script src="angular.js"></script> <script> let app = angular.createModule('demo', []) .controller('WelcomeController', ['$scope', function($scope) { $scope.greeting = 'Welcome!'; }]); angular.bootstrap(document, ['demo']); </script> </body> </html> ```
      Parameters:
      element - DOM element which is the root of AngularTS application.
      modules - an array of modules to load into the application. Each item in the array should be the name of a predefined module or a (DI annotated) function that will be invoked by the injector as a `config` block. See `angular.createModule()` and `angular.getModule()`.
      Returns:
      Method result.
    • bootstrap

      @JsOverlay public final InjectorService<Object> bootstrap(elemental2.dom.HTMLElement element, elemental2.core.JsArray<Object> modules)
      Use this function to manually start up AngularTS application. AngularTS will detect if it has been loaded into the browser more than once and only allow the first loaded script to be bootstrapped and will report a warning to the browser console for each of the subsequent scripts. This prevents strange results in applications, where otherwise multiple instances of AngularTS try to work on the DOM. **Note:** Do not bootstrap the app on an element with a directive that uses transclusion, such as `ng-if`, `ng-include`, or `ng-view`. Doing this misplaces the app root element and injector, causing animations to stop working and making the injector inaccessible from outside the app. ```html <!doctype html> <html> <body> <div ng-controller="WelcomeController"> {{greeting}} </div> <script src="angular.js"></script> <script> let app = angular.createModule('demo', []) .controller('WelcomeController', ['$scope', function($scope) { $scope.greeting = 'Welcome!'; }]); angular.bootstrap(document, ['demo']); </script> </body> </html> ```
      Parameters:
      element - DOM element which is the root of AngularTS application.
      modules - an array of modules to load into the application. Each item in the array should be the name of a predefined module or a (DI annotated) function that will be invoked by the injector as a `config` block. See `angular.createModule()` and `angular.getModule()`.
      Returns:
      Method result.
    • bootstrap

      @JsOverlay public final InjectorService<Object> bootstrap(String element, elemental2.core.JsArray<Object> modules)
      Use this function to manually start up AngularTS application. AngularTS will detect if it has been loaded into the browser more than once and only allow the first loaded script to be bootstrapped and will report a warning to the browser console for each of the subsequent scripts. This prevents strange results in applications, where otherwise multiple instances of AngularTS try to work on the DOM. **Note:** Do not bootstrap the app on an element with a directive that uses transclusion, such as `ng-if`, `ng-include`, or `ng-view`. Doing this misplaces the app root element and injector, causing animations to stop working and making the injector inaccessible from outside the app. ```html <!doctype html> <html> <body> <div ng-controller="WelcomeController"> {{greeting}} </div> <script src="angular.js"></script> <script> let app = angular.createModule('demo', []) .controller('WelcomeController', ['$scope', function($scope) { $scope.greeting = 'Welcome!'; }]); angular.bootstrap(document, ['demo']); </script> </body> </html> ```
      Parameters:
      element - DOM element which is the root of AngularTS application.
      modules - an array of modules to load into the application. Each item in the array should be the name of a predefined module or a (DI annotated) function that will be invoked by the injector as a `config` block. See `angular.createModule()` and `angular.getModule()`.
      Returns:
      Method result.
    • call

      public elemental2.promise.Promise<Object> call(String input)
      Await result. Accepts a single string: `"<target>.<expression>"`
      Parameters:
      input - Value supplied for the input parameter.
      Returns:
      Method result.
    • createModule

      public NgModule createModule(String name, elemental2.core.JsArray<String> requires, Object configFn)
      Creates or replaces an AngularTS module. A module collects services, directives, controllers, filters, workers, WebAssembly modules, and configuration for an application.
      Parameters:
      name - The name of the module to create.
      requires - The modules required by the new module.
      configFn - Optional configuration function for the module that gets passed to `NgModule.config()`.
      Returns:
      Method result.
    • dispatchEvent

      public boolean dispatchEvent(elemental2.dom.Event event)
      Dispatches an invocation event to either an injectable service or a named scope. The event `type` identifies the target and the payload contains the expression to evaluate against that target.
      Parameters:
      event - Value supplied for the event parameter.
      Returns:
      Method result.
    • emit

      public void emit(String input)
      Fire-and-forget. Accepts a single string: `"<target>.<expression>"`
      Parameters:
      input - Value supplied for the input parameter.
    • errorFormattingConfig

      public ErrorFormattingConfig errorFormattingConfig(ErrorFormattingConfig config)
      Configure how values embedded in framework error messages are formatted.
      Parameters:
      config - Value supplied for the config parameter.
      Returns:
      Method result.
    • getController

      public Scope getController(elemental2.dom.Element element, String name)
      Retrieve the controller instance cached on a compiled DOM element.
      Parameters:
      element - The DOM element to get data from.
      name - Controller name.
      Returns:
      Method result.
    • getInjector

      public InjectorService<Object> getInjector(elemental2.dom.Element element)
      Retrieve the injector cached on a bootstrapped DOM element.
      Parameters:
      element - Value supplied for the element parameter.
      Returns:
      Method result.
    • getModule

      public NgModule getModule(String name)
      Retrieves an existing module.
      Parameters:
      name - The name of the module to retrieve.
      Returns:
      Method result.
    • getNormalizedAttr

      public String getNormalizedAttr(Node element, String normalizedName)
      Read an element attribute by normalized directive-style name.
      Parameters:
      element - Value supplied for the element parameter.
      normalizedName - Value supplied for the normalizedName parameter.
      Returns:
      Method result.
    • getNormalizedAttrName

      public String getNormalizedAttrName(Node element, String normalizedName)
      Return the actual DOM attribute name for a normalized directive-style name.
      Parameters:
      element - Value supplied for the element parameter.
      normalizedName - Value supplied for the normalizedName parameter.
      Returns:
      Method result.
    • getScope

      public Scope getScope(elemental2.dom.Element element)
      Retrieve the scope cached on a compiled DOM element.
      Parameters:
      element - The DOM element to get data from.
      Returns:
      Method result.
    • getScopeByName

      public Scope getScopeByName(String name)
      Find a scope by its registered `scopeName`.
      Parameters:
      name - Scope name to search for.
      Returns:
      Method result.
    • hasNormalizedAttr

      public boolean hasNormalizedAttr(Node element, String normalizedName)
      Return whether an element has an attribute matching a normalized name.
      Parameters:
      element - Value supplied for the element parameter.
      normalizedName - Value supplied for the normalizedName parameter.
      Returns:
      Method result.
    • injector

      public InjectorService<Object> injector(elemental2.core.JsArray<Object> modules)
      Create a standalone injector without bootstrapping the DOM.
      Parameters:
      modules - Module names or config functions to load.
      Returns:
      Method result.
    • registerNgModule

      public NgModule registerNgModule()
      Registers the configured built-in `ng` module for this runtime instance.
      Returns:
      Method result.
    • tags

      public Object tags(String namespaceUri)
      JSX-free real-DOM tag factories for programmatic component views.
      Parameters:
      namespaceUri - Value supplied for the namespaceUri parameter.
      Returns:
      Method result.