aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/coffee/angular_coffee.snippets
blob: f98cae355ba4fee77aaded9490f673e9bfc61ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
## Global Snippets
# Define a new Angular Controller;
# You can change the controller name and parameters
snippet ngc
	${1:controllerName} = (${2:scope}, ${3:injectables}) ->
		${4}
# angular.foreach loop
snippet ngfor
	angular.forEach ${1:iterateOver}, (value, key) ->
		${2}
## Module Based Snippets
# A new angular module without a config function
snippet ngm
	angular.module '${1:moduleName}', [${2:moduleDependencies}]
	${3}
# A new angular module without a config function and a variable assignment
snippet ngma
	${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
	${3}
# A new angular module with a config function
snippet ngmc
	${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
		${4}
	)
# A factory in a module
snippet ngmfa
	factory '${1:factoryName}', (${2:dependencies}) ->
		${3}
# Define an Angular Module Service to be attached to a previously defined module
# You can change the service name and service injectables
snippet ngms
	service '${1:serviceName}', (${2:injectables}) ->
		${3}
# Define an Angular Module Filter to be attached to a previously defined module
# You can change the filter name
snippet ngmfi
	filter '${1:filterName}', (${2:injectables}) ->
		(input, ${3:args}) ->
			${4}
## Route Based Snippets
# Defines a when condition of an AngularJS route
snippet ngrw
	$routeProvider.when '${1:url}',
		templateUrl: '${2:templateUrl}'
		controller: '${3:controller}'
	${4}
# Defines a when condition of an AngularJS route with the resolve block
snippet ngrwr
	$routeProvider.when '${1:url}',
		templateUrl: '${2:templateUrl}'
		controller: '${3:controller}'
		resolve:
			${4}
	${5}
# Defines an otherwise condition of an AngularJS route
snippet ngro
	$routeProvider.otherwise redirectTo: '${1:url}'
	${2}
## Scope Related Snippets
# Define a new $scope'd function (usually inside an AngularJS Controller)
# You can change the function name and arguments
snippet $f
	$scope.${1:functionName} = (${2:args}) ->
		${3}
# Defines a new $scope'd variable inside an AngularJS controller
snippet $v
	$scope.${1:variable} = ${2:value}
	${3}
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
snippet $va
	$scope.${1:variable} = ${2:variable}
	${3}
# Define a $watch for an expression
# You can change the expression to be watched
snippet $w
	$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
		${2}
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
# You can change the event name to listen on
snippet $on
	$scope.$on '${1:eventName}', (event, ${2:args}) ->
		${3}
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $b
	$scope.$broadcast '${1:eventName}', ${2:eventArgs}
	${3}
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $e
	$scope.$emit '${1:eventName}', ${2:eventArgs}
	${3}
## Directive related snippets
# A compile function
snippet ngdcf
	compile = (tElement, tAttrs, transclude) ->
		(scope, element, attrs) ->
			${1}
# A linking function in a directive
snippet ngdlf
	(scope, element, attrs${1:ctrl}) ->
		${2}
# A directive with a compile function
snippet ngdc
	directive '${1:directiveName}', factory = (${2:injectables}) ->
		directiveDefinitionObject =
			${3:directiveAttrs}
			compile: compile = (tElement, tAttrs, transclude) ->
				(scope, element, attrs) ->
		directiveDefinitionObject
# A directive with a linking function only
snippet ngdl
	.directive('${1:directiveName}', (${2:directiveDeps}) ->
		(scope, element, attrs${3:ctrl}) ->
			${4}
	)