diff --git a/ngreact/ngreact-tests.tsx b/ngreact/ngreact-tests.tsx new file mode 100644 index 0000000000..013e3f2f6b --- /dev/null +++ b/ngreact/ngreact-tests.tsx @@ -0,0 +1,38 @@ +/// +/// + +import * as React from "react"; +import { ReactDirective } from "ngreact"; + +const app = angular.module("app", ["react"]); + +app.directive('helloComponent', function(reactDirective: ReactDirective) { + return reactDirective(HelloComponent); +}); + +app.directive('helloComponent', function(reactDirective: ReactDirective) { + return reactDirective('HelloComponent'); +}); + +app.directive('hello', function(reactDirective: ReactDirective) { + return reactDirective(HelloComponent, ['fname', 'lname']); +}); + +app.directive('hello', function(reactDirective: ReactDirective) { + return reactDirective(HelloComponent, undefined, {restrict: 'C'}); +}); + +app.directive('helloComponent', function(reactDirective: ReactDirective, $location: ng.ILocationService) { + return reactDirective(HelloComponent, undefined, {}, { $location }); +}); + +var HelloComponent = React.createClass({ + propTypes: { + fname : React.PropTypes.string.isRequired, + lname : React.PropTypes.string.isRequired + }, + render: function() { + return Hello {this.props.fname} {this.props.lname}; + } +}) +app.value('HelloComponent', HelloComponent); diff --git a/ngreact/ngreact.d.ts b/ngreact/ngreact.d.ts new file mode 100644 index 0000000000..9c3ecbec11 --- /dev/null +++ b/ngreact/ngreact.d.ts @@ -0,0 +1,14 @@ +// Type definitions for ngReact v0.3.0 +// Project: https://github.com/ngReact/ngReact +// Definitions by: Vicky Lai +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "ngreact" { + type ReactDirective = (reactComponentName: string | __React.ComponentClass, + propNames?: string[], + conf?: Object, + injectableProps?: Object) => angular.IDirective; +}