ulfryk / angular-typescript Goto Github PK
View Code? Open in Web Editor NEWTypeScript 1.7 annotations (decorators) for AngularJS 1.x
License: Do What The F*ck You Want To Public License
TypeScript 1.7 annotations (decorators) for AngularJS 1.x
License: Do What The F*ck You Want To Public License
The idea from Angular 2
@Component({
selector: "ot-site"
})
@View({
templateUrl: "ot-site.html"
})
class OtSite() {
constructor () {
}
// public methods here
}
https://github.com/nodeframe/angular-typescript
Modify to be
@at.service(module:string|angular.IModule, serviceName?: string)
@at.inject(dependencyOne: string, ...dependencies?: string[])
@at.controller(module: string|angular.IModule, controllerName?: string)
@at.directive(module: string|angular.IModule, directiveName?: string)
@at.classFactory(module: string|angular.IModule, className?: string)
@at.resource(module: string|angular.IModule, resourceClassName?: string)
if name is undefined, that use class name instead
@service('test')
class TestService {
.....
}
and the somewhere else
…
constructor(
@inject('testService') TestService: TestService
) {
this.testService = new TestService();
}
…
I'm using typings
with jspm
, I need to provide typings
a path for the ambient declarations
Is it possible to implement the use of this library through typings?
Or please give instructions on how to use this library in the project.
I don't get it here, the injection of
@directive('ngModuleName', 'atSomeDirective')
class SomeDirectiveController {
public static controllerAs: 'someDirectiveCtrl';
public static templateUrl: string = '/partials/some-directive.html';
public static link: angular.IDirectiveLinkFn = (scope, element, attrs, ctrl: SomeDirectiveController) => {
ctrl.init(attrs.atSomeDirective);
};
constructor(
@inject('$scope') private $$scope: angular.IScope,
@inject('$parse') private $$parse: angular.IParseService
) {
// do stuff with $$scope and $$parse;
}
public init(anArg: string): boolean {
// do some stuff with this.$$parse and this.$$scope
}
}
It would be better is this library has the name of angular-typescript-annotations
or ng-ts-annotations
. In that way users don't get confused thinking that this library is a wrapper or a rewriting of angular in typescript
There is no entry point for the package, consider doing what is being done at test/module.ts
as entry point for the module
Hey,
firstly, this repo is really great :)
Okay, this is more a question than an issue: Can you go a little bit deeper into the usage of resource decorators? I don't really get it.
Here are some problems i have:
Custom actions are only supported for configuration, but there are no type definitions. Am I right?
example:
class SomeResource {
static actions = { getByName: { ... } }
}
var resource = new SomeResource();
resource.getByName() // would work in the native JS-world but TypeScript throws a compilation error
// because getByName doesn't exist on SomeResource
I thought about using member decorators for custom actions like:
@action(..)
$getByName: (params: {name: string}) => ng.IPromise<Something>
// Another problem results from the naming conventions of static custom actions => `getByName`.
// But maybe it should be defined in an separate Interface like I mentioned on 2.
Sure, another solution would be to create an Interface. But such an interface couldn't be implemented by the resource class (So very ugly: There is no connection between the class and the interface). Another issue would be, that you have to define a custom action on 3 different places (SomeResourceInstanceInterface
, SomeResourceClassInterface
and the configuration itself)
In at.Resource
there are non-static as well as static members defined. But when a resource is used it will look like this:
@service('test', 'someService')
@inject('SomeResource');
class SomeService() {
constructor(SomeResource: ???) {}
}
In my opinion it would make more sense to separate the static functions in an extra Interface (like SomeResourceClassInterface
). What do you think? Because SomeResource
should never be used directly without injecting it, the static members won't ever be used.
Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.