1
0
Fork 0
mirror of synced 2024-11-23 01:05:34 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/coffee/angular_coffee.snippets

116 lines
3.7 KiB
Text
Raw Normal View History

2014-03-11 16:59:33 -04:00
## 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}
)