* @ngdoc function * @name angular.bind * @module ng * @kind function * * @description * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for * `fn`). You can supply optional `args` that are prebound to the function. This feature is also * known as [part
(self, fn)
| 1338 | * @returns {function()} Function that wraps the `fn` with all the specified bindings. |
| 1339 | */ |
| 1340 | function bind(self, fn) { |
| 1341 | var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : []; |
| 1342 | if (isFunction(fn) && !(fn instanceof RegExp)) { |
| 1343 | return curryArgs.length |
| 1344 | ? function() { |
| 1345 | return arguments.length |
| 1346 | ? fn.apply(self, concat(curryArgs, arguments, 0)) |
| 1347 | : fn.apply(self, curryArgs); |
| 1348 | } |
| 1349 | : function() { |
| 1350 | return arguments.length |
| 1351 | ? fn.apply(self, arguments) |
| 1352 | : fn.call(self); |
| 1353 | }; |
| 1354 | } else { |
| 1355 | // In IE, native methods are not functions so they cannot be bound (note: they don't need to be). |
| 1356 | return fn; |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | |
| 1361 | function toJsonReplacer(key, value) { |
no test coverage detected