|
| 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: |
0 commit comments