# ngmaterial-mdcompiler

> The $mdCompiler service ripped from angular material

Latest version **1.0.2** (published 2016-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngmaterial-mdcompiler
pnpm add ngmaterial-mdcompiler
yarn add ngmaterial-mdcompiler
bun add ngmaterial-mdcompiler
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-11-09 |
| First published | 2016-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrew Joslin |
| Maintainers | andytjoslin |
| Keywords | compile, link, scope, angular |

## Links

- npm: https://www.npmjs.com/package/ngmaterial-mdcompiler
- Repository: https://github.com/ajoslin/ngmaterial-mdcompiler
- Homepage: https://github.com/ajoslin/ngmaterial-mdcompiler#readme
- Issues: https://github.com/ajoslin/ngmaterial-mdcompiler/issues
- npm.io page: https://npm.io/package/ngmaterial-mdcompiler

## Dependencies (1)

- [angular](https://npm.io/package/angular.md) ^1.5.8

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2016-11-09
- 1.0.1 — 2016-09-19
- 1.0.0 — 2016-09-19

## README

# ngmaterial-mdcompiler [![Build Status](https://travis-ci.org/ajoslin/ngmaterial-mdcompiler.svg?branch=master)](https://travis-ci.org/ajoslin/ngmaterial-mdcompiler)

> The $mdCompiler service ripped from angular material

[Link to code](https://github.com/angular/material/blob/08319e7cd923b1c566f72e35a44dc2c8a4f10c74/src/core/services/compiler/compiler.js)

## Install

```
$ npm install --save ngmaterial-mdcompiler
```

## Usage

```js
const angular = require('angular')
const mdCompiler = require('ngmaterial-mdcompiler')

angular.module('myApp', [
  require('ngmaterial-mdcompiler')
])
  .controller('MyCtrl', function ($mdCompiler) {
    // $mdCompiler.compile({ ... })
  })
```

## API

The module is exposed as a string representing the module's name for easy inclusion (see above).

It creates a service `$mdCompiler`.

### `$mdCompiler.compile(options) -> Promise<compileData>`

A helper to compile an HTML template/templateUrl with a given controller, locals, and scope.

#### `options`

An options object, with the following properties:

- `controller` - `{(string=|function()=}` Controller fn that should be associated with
  newly created scope or the name of a registered controller if passed as a string.
- `controllerAs` - `{string=}` A controller alias name. If present the controller will be
  published to scope under the `controllerAs` name.
- `template` - `{string=}` An html template as a string.
- `templateUrl` - `{string=}` A path to an html template.
- `transformTemplate` - `{function(template)=}` A function which transforms the template after
  it is loaded. It will be given the template string as a parameter, and should
  return a a new string representing the transformed template.
- `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
  be injected into the controller. If any of these dependencies are promises, the compiler
  will wait for them all to be resolved, or if one is rejected before the controller is
  instantiated `compile()` will fail..
  * `key` - `{string}`: a name of a dependency to be injected into the controller.
  * `factory` - `{string|function}`: If `string` then it is an alias for a service.
    Otherwise if function, then it is injected and the return value is treated as the
    dependency. If the result is a promise, it is resolved before its value is
    injected into the controller.
 - `locals` - `{object}`: The locals which will be passed into the controller once `link` is
 called. If `bindToController` is true, they will be copied to the ctrl instead
 - `bindToController` - `bool`: bind the locals to the controller, instead of passing them in.

#### returns `Promise<compileData>`

Returns a promise, which will be resolved with a `compileData` object.
`compileData` has the following properties:

- `element` - `{element}`: an uncompiled element matching the provided template.
- `link` - `{function(scope)}`: A link function, which, when called, will compile
  the element and instantiate the provided controller (if given).

## License

[MIT © Google](https://github.com/angular/material/blob/master/LICENSE)

---
_Source: https://npm.io/package/ngmaterial-mdcompiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
