angularjs

package module
v0.0.0-...-1492dd8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2021 License: BSD-2-Clause Imports: 3 Imported by: 0

README

go-angularjs

A wrapper for AngularJS to be used with GopherJS.

Project status

Angularjs is being used less and there are better/newer alternatives that should be used. The support for angularjs will stop on December 31, 2021(https://docs.angularjs.org/misc/version-support-status).

Therefore this project is archived and will not be maintained anymore.

Examples

Run the examples in the example directory with gopherjs serve.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeFuncInjectable

func MakeFuncInjectable(f interface{}) (jsFunc js.S, err error)

MakeFuncInjectable returns a func that transforms *js.Object's to the corresponding go types.

func RegisterResource

func RegisterResource(resourceType reflect.Type, angularName string, f func(obj *js.Object) reflect.Value)

RegisterResource registers a resource that can be injected

func Service

func Service(name string) *js.Object

Service gets a service trough the global $injector

Types

type Deferred

type Deferred struct {
	*js.Object
}

Deferred is angulars defer object returned from $q.defer()

func (*Deferred) Promise

func (d *Deferred) Promise() *js.Object

Promise is angulars deferred.promis

func (*Deferred) Reject

func (d *Deferred) Reject(data interface{}) *js.Object

Reject see Resolve

func (*Deferred) Resolve

func (d *Deferred) Resolve(data interface{}) *js.Object

Resolve will resolve the promise. Only js objects with an initialized object can be given. An empty javascript object can be created with 'js.Global.Get("Object").New()'

type Directive

type Directive struct {
	Restrict    string
	Link        func(scope *Scope, el *Element, attrs map[string]interface{})
	TemplateURL string
	Scope       []string
}

Directive is the go variant of an angular directive At least a templateURL should be given.

type Element

type Element struct{ *js.Object }

Element is a basic jqLite angular element

func (*Element) On

func (e *Element) On(events string, handler func(*Event))

On registers for events on the given element

func (*Element) Prop

func (e *Element) Prop(name string) *js.Object

Prop calls the given property

func (*Element) SetProp

func (e *Element) SetProp(name, value interface{})

SetProp sets the given property

func (*Element) SetVal

func (e *Element) SetVal(value interface{})

SetVal sets val

func (*Element) Val

func (e *Element) Val() *js.Object

Val returns val

type Event

type Event struct {
	*js.Object
}

Event is an angular event from $emit/$broadcast

func (*Event) CurrentScope

func (e *Event) CurrentScope() *Scope

CurrentScope see $event.currentScope

func (*Event) DefaultPrevented

func (e *Event) DefaultPrevented() bool

DefaultPrevented see $event.defaultPrevented

func (*Event) Name

func (e *Event) Name() string

Name see $event.name

func (*Event) PreventDefault

func (e *Event) PreventDefault()

PreventDefault see $event.preventDefault()

func (*Event) TargetScope

func (e *Event) TargetScope() *Scope

TargetScope see $event.targetScope

type Inject

type Inject struct {
	// contains filtered or unexported fields
}

Inject represents a resource that can be injected into an controller/directive/route-resolve func

func GetFuncInjectables

func GetFuncInjectables(f interface{}) (injects []*Inject, callable reflect.Value, err error)

GetFuncInjectables reads the function arguments and transforms them to *Inject resources. If an arguments is not found the returns an error.

func GetResource

func GetResource(resourceType reflect.Type) *Inject

GetResource returns the resource for a given reflect.Type

type Location

type Location struct {
	*js.Object
}

Location implements $location

func (*Location) CurrentPath

func (l *Location) CurrentPath() string

func (*Location) Path

func (l *Location) Path(p string)

func (*Location) Search

func (l *Location) Search() LocationSearch

type LocationProvider

type LocationProvider struct {
	*js.Object
}

func (*LocationProvider) Html5Mode

func (l *LocationProvider) Html5Mode(on bool)

type LocationSearch

type LocationSearch map[string]string

func (LocationSearch) Get

func (l LocationSearch) Get(key string) string

func (LocationSearch) Has

func (l LocationSearch) Has(key string) bool

type Module

type Module struct{ *js.Object }

Module is an angular module

func NewModule

func NewModule(name string, requires []string, configFn interface{}) *Module

NewModule makes a new angular module

func (*Module) NewController

func (m *Module) NewController(name string, constructor interface{})

NewController creates a new controller on the given module The arguments of the controller should only contain resources that have been added with a call to RegisterResouce

func (*Module) NewDirective

func (m *Module) NewDirective(name string, f interface{})

NewDirective registers a directive. The fomat should be: func(.... resources) Directive

func (*Module) Run

func (m *Module) Run(fn interface{})

Run is the go implementation of .run in angularjs

type Q

type Q struct {
	*js.Object
}

Q represets angulars $q

func (*Q) Defer

func (q *Q) Defer() *Deferred

type RootScope

type RootScope struct {
	*Scope
}

RootScope is the angular $rootScope

type Route

type Route struct {
	*js.Object
}

Route is the angular $route

func (*Route) Params

func (r *Route) Params() map[string]string

Params returns the $route.params value

type RouteConfig

type RouteConfig struct {
	TemplateURL string
	Template    string
	Controller  string
	Resolve     map[string]interface{}
}

RouteConfig is an implementation of the config used to $routeProvider.when

type RouteParams

type RouteParams struct {
	*js.Object
}

RouteParams is a copy of $routeParams

func (RouteParams) Get

func (r RouteParams) Get(key string) string

Get returns the value at the given key

type RouteProvider

type RouteProvider struct {
	*js.Object
}

RouteProvider implements $routeProvider

func (*RouteProvider) Otherwise

func (r *RouteProvider) Otherwise(config RouteConfig)

Otherwise is used as a 404

func (*RouteProvider) When

func (r *RouteProvider) When(url string, config RouteConfig)

When is used to register a new URL

type Scope

type Scope struct {
	*js.Object
}

Scope is the angular $scope

func (*Scope) Apply

func (s *Scope) Apply(f func())

Apply is the angular $scope.$apply and should be called when changing values trough goroutines or event listeners

func (*Scope) Broadcast

func (s *Scope) Broadcast(event string, args ...interface{})

Broadcast is a copy of $broadcast

func (*Scope) CopyScope

func (s *Scope) CopyScope() *js.Object

CopyScope is used to provide a *js.Object scope for structs inside a controller

func (*Scope) Emit

func (s *Scope) Emit(event string, args ...interface{})

Emit is a copy of $emit

func (*Scope) EvalAsync

func (s *Scope) EvalAsync(f func())

func (*Scope) Listen

func (s *Scope) Listen(event string, listener interface{})

Listen binds to the event and removes it if the scope is destroyed

func (*Scope) On

func (s *Scope) On(event string, listener interface{}) (unregisterFunc func())

On registers the given listener for an event. Returns an unregister func for the event format of listener: func(ev *Event, args ...interface{})

func (*Scope) Watch

func (s *Scope) Watch(key string, f func(newValue interface{}, oldValue interface{}))

Watch is the angular $watch

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL