Merge pull request #9926 from velveret/ngreact

Add typings for ngreact
This commit is contained in:
Mohamed Hegazy
2016-07-01 15:09:56 -07:00
committed by GitHub
2 changed files with 52 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="ngreact.d.ts"/>
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 <span>Hello {this.props.fname} {this.props.lname}</span>;
}
})
app.value('HelloComponent', HelloComponent);
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for ngReact v0.3.0
// Project: https://github.com/ngReact/ngReact
// Definitions by: Vicky Lai <https://github.com/velveret>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts"/>
/// <reference path="../react/react.d.ts"/>
declare module "ngreact" {
type ReactDirective = (reactComponentName: string | __React.ComponentClass<any>,
propNames?: string[],
conf?: Object,
injectableProps?: Object) => angular.IDirective;
}