Skip to content

Commit ad38f34

Browse files
committed
Init commit, break angular snippets out into their own repo for friendly submodule sharing
0 parents  commit ad38f34

File tree

3 files changed

+211
-0
lines changed

3 files changed

+211
-0
lines changed

html/angular_html.snippets

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
snippet ngindex "Basic Angular Bootstrap (For Prototyping)"
4+
<html>
5+
<head>
6+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.0.1}/angular.js"></script>
7+
</head>
8+
<body ng-app>
9+
10+
$0
11+
12+
</body>
13+
</html>
14+
endsnippet
15+
16+
17+
snippet ngsa "Angular Source Script"
18+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/${1:1.0.1}/angular.js"></script>
19+
20+
$0
21+
endsnippet
22+
23+
24+
snippet ngst "A script tag holding Angular template"
25+
<script type="text/ng-template" id="${1:id}">
26+
$0
27+
</script>
28+
endsnippet
29+
30+
31+
snippet ngb "A binding in AngularJS"
32+
{{${1:binding}}}$0
33+
endsnippet
34+
35+
36+
# vim:ft=snippets:

javascript/angular_js.snippets

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
2+
3+
snippet ngc "Define a new Angular Controller. You can change the controller name and parameters."
4+
var ${1:controllerName} = function(${2:scope}, ${3:injectables}) {
5+
$0
6+
}
7+
endsnippet
8+
9+
10+
snippet ngfor "angular.foreach loop"
11+
angular.forEach(${1:iterateOver}, function(value, key){
12+
$0
13+
});
14+
endsnippet
15+
16+
17+
snippet ngm "A new angular module without a config function."
18+
angular.module('${1:moduleName}',[${2:moduleDependencies}]);
19+
$0
20+
endsnippet
21+
22+
23+
snippet ngma "A new angular module without a config function and a variable assigment."
24+
var ${1:moduleName} = angular.module('$1$',[${2:moduleDeps}]);
25+
$0
26+
endsnippet
27+
28+
29+
snippet ngmc "A new angular module with a config function"
30+
var ${1:moduleName} = angular.module('$1',[${2:moduleDeps}], function(${3:configDeps}){
31+
$0
32+
});
33+
endsnippet
34+
35+
36+
snippet ngmfa "A factory in a module"
37+
factory('${1:factoryName}', function(${2:dependencies}){
38+
$0
39+
});
40+
endsnippet
41+
42+
43+
snippet ngms "Define an Angular Module Service to be attached to a previously defined module. You can change the service name and service injectables."
44+
service('${1:serviceName}', function(${2:injectables}) {
45+
$0
46+
});
47+
endsnippet
48+
49+
50+
snippet ngmfi "Define an Angular Module Filter to be attached to a previously defined module. You can change the filter name."
51+
filter('${1:filterName}', function(${2:injectables}) {
52+
return function(input, ${3:args}) {
53+
$0
54+
};
55+
})
56+
endsnippet
57+
58+
59+
60+
# Route Based Snippets
61+
snippet ngrw "Defines a when condition of an AngularJS route."
62+
$routeProvider.when('${1:url}', {
63+
templateUrl: '${2:templateUrl}',
64+
controller: '${3:controller}'
65+
});
66+
$0
67+
endsnippet
68+
69+
70+
snippet ngro "Defines an otherwise condition of an AngularJS route."
71+
$routeProvider.otherwise(
72+
redirectTo : '${1:url}'
73+
});
74+
$0
75+
endsnippet
76+
77+
78+
# Scope Related Snippets
79+
snippet $f "Define a new $scope'd function (usually inside an AngularJS Controller). You can change the function name and arguments."
80+
$scope.${1:functionName} = function(${2:args}) {
81+
$0
82+
};
83+
endsnippet
84+
85+
86+
snippet $v "Defines a new $scope'd variable inside an AngularJS controller."
87+
$scope.${1:variable} = ${2:value}
88+
$0
89+
endsnippet
90+
91+
92+
snippet $va "Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a contstructor arguments."
93+
$scope.${1:variable} = ${2:variable};
94+
$0
95+
endsnippet
96+
97+
98+
snippet $w "Define a $watch for an expression. You can change the expression to be watched."
99+
$scope.$watch('${1:watchExpr}',function(newValue, oldValue){
100+
$0
101+
});
102+
endsnippet
103+
104+
105+
snippet $on "Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller. You can change the event name to listen on."
106+
$scope.$on('${1:eventName}', function(event, ${2:args}) {
107+
$0
108+
});
109+
endsnippet
110+
111+
112+
snippet $b "Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function. You can change the event name and optional event arguments."
113+
$scope.$broadcast('${1:eventName}', ${2:eventArgs});
114+
$0
115+
endsnippet
116+
117+
118+
snippet $e "Define an $emit for a $scope inside an Angular Controller / Angular Controller Function. You can change the event name and optional event arguments."
119+
$scope.$emit('${1:eventName}', ${2:eventArgs});
120+
$0
121+
endsnippet
122+
123+
124+
# Directive related snippets
125+
snippet ngdcf "A compile function"
126+
function compile(tElement, tAttrs, transclude) {
127+
return function (scope, element, attrs) {
128+
$0
129+
}
130+
}
131+
endsnippet
132+
133+
134+
snippet ngdlf "A linking function in a directive."
135+
function (scope, element, attrs${1:ctrl}) {
136+
$0
137+
}
138+
endsnippet
139+
140+
141+
snippet ngdc "A directive with a compile function"
142+
directive('${1:directiveName}', function factory(${2:injectables}) {
143+
var directiveDefinitionObject = {
144+
${3:directiveAttrs},
145+
compile: function compile(tElement, tAttrs, transclude) {
146+
return function (scope, element, attrs) {
147+
148+
}
149+
}
150+
};
151+
return directiveDefinitionObject;
152+
});
153+
endsnippet
154+
155+
156+
snippet ngdl "A directive with a linking function only."
157+
.directive('${1:directiveName}', function(${2:directiveDeps}) {
158+
return function(scope, element, attrs${3:ctrl}) {
159+
$0
160+
}
161+
});
162+
endsnippet
163+
164+
165+
# vim:ft=snippets:

readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Angular Vim Ultisnips
2+
3+
4+
###Installation:
5+
6+
- `git submodule add git@github.com:matthewsimo/angular-vim-ultisnips.git /path/you/want/it/`
7+
- add it do your list of `g:UltiSnipsSnippetDirectories` and your should be set
8+
9+
10+
Feel free to submit pull requests!

0 commit comments

Comments
 (0)