mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
@@ -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);
|
||||
Vendored
+14
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user