{"id":21023182,"url":"https://github.com/tkssharma/angular-hacks","last_synced_at":"2026-04-13T20:31:59.059Z","repository":{"id":151800252,"uuid":"86540928","full_name":"tkssharma/Angular-hacks","owner":"tkssharma","description":"Code snippets for Angular hacks ","archived":false,"fork":false,"pushed_at":"2017-04-23T14:51:22.000Z","size":952,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-12T08:41:24.678Z","etag":null,"topics":["angular","javascript","node"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=Ob_vxTF7rHA\u0026list=PLIGDNOJWiL19nAuqIbJOUcXqxRnSn6IGD","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tkssharma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-29T05:14:11.000Z","updated_at":"2017-03-29T05:16:08.000Z","dependencies_parsed_at":"2023-07-31T23:47:55.276Z","dependency_job_id":null,"html_url":"https://github.com/tkssharma/Angular-hacks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tkssharma/Angular-hacks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkssharma%2FAngular-hacks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkssharma%2FAngular-hacks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkssharma%2FAngular-hacks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkssharma%2FAngular-hacks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkssharma","download_url":"https://codeload.github.com/tkssharma/Angular-hacks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkssharma%2FAngular-hacks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31770718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","javascript","node"],"created_at":"2024-11-19T11:17:08.136Z","updated_at":"2026-04-13T20:31:59.042Z","avatar_url":"https://github.com/tkssharma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AngularJS example snippets 1.5\n\n# Why AngularJS?\n\nHTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.\n\n# Alternatives\n\nOther frameworks deal with HTML’s shortcomings by either abstracting away HTML, CSS, and/or JavaScript or by providing an imperative way for manipulating the DOM. Neither of these address the root problem that HTML was not designed for dynamic views.\n\n# Extensibility\n\nAngularJS is a toolset for building the framework most suited to your application development. It is fully extensible and works well with other libraries. Every feature can be modified or replaced to suit your unique development workflow and feature needs. Read on to find out how.\n\n### Angular js hacks #01 $scope.$apply\n\n```bash\nangular.module('myApp',[]).controller('MessageController', function($scope) {\n\n  $scope.getMessage = function() {\n    setTimeout(function() {\n      $scope.message = 'Fetched after 3 seconds';\n      $scope.$apply()\n      console.log('message:'+$scope.message);\n    }, 2000);\n  }\n  $scope.getMessage();\n});\n```\n\n\n### Angular js hacks #02 $scope.$watch\n\n```bash\n$scope.$watch(\"message\", function(newval, oldval) {\n    console.log(\"new message: \" + newval);\n    console.log(\"old message: \" + oldval);\n});\n$scope.$watchCollection(\"colors\", function(newList, oldList) {\n    console.log(\"new list: \" + newList);\n    console.log(\"old list: \" + oldList);\n  });\n});\n```\n\n### Angular js Testing #03 ngMock : controllers\n```bash\ndescribe('Testing for  Controllers', function() {\n\t\n\tvar results = [\n\t      {\n\t         \"Title\":\"Star Wars: Episode IV - A New Hope\",\n\t         \"imdbID\":\"tt0076759\"\n\t      },\n\t      {\n\t         \"Title\":\"Star Wars: Episode V - The Empire Strikes Back\",\n\t         \"imdbID\":\"tt0080684\"\n\t      },\n\t      {\n\t         \"Title\":\"Star Wars: Episode VI - Return of the Jedi\",\n\t         \"imdbID\":\"tt0086190\"\n\t      }\n\t  ];\n\tvar $scope;\n\tvar $interval;\n\n\tbeforeEach(module('movieApp'));\n\n\tbeforeEach(inject(function(_$q_, _PopularMovies_) {\n\t\tspyOn(_PopularMovies_, 'get').and.callFake(function() {\n\t\t\tvar deferred = _$q_.defer();\n\t\t\tdeferred.resolve(['tt0076759', 'tt0080684', 'tt0086190']);\n\t\t\treturn deferred.promise;\n\t\t});\n\t}));\n});\n```\n\n### Angular js Testing #03 ngMock : directives\n```bash\ndescribe('Movie Result Directive', function() {\n    var $compile;\n    var $rootScope;\n\n    beforeEach(module('movieApp'));\n\n    beforeEach(inject(function(_$compile_, _$rootScope_) {\n    \t$compile = _$compile_;\n    \t$rootScope = _$rootScope_;\n    }));\n\n\tit('should output movie result to expected HTML format', function() {\n\t\t$rootScope.result = result;\n\t\tvar element = $compile('\u003cmovie-result result=\"result\"\u003e\u003c/movie-result\u003e')($rootScope);\n\t\t$rootScope.$digest();\n\t\texpect(element.html()).toBe(expectedHtml);\n    expect($rootScope.$countChildScopes()).toBe(1);\n    expect($rootScope.$countWatchers()).toBe(10);\n\t});\n});\n```\n\n### Angular js Testing #03 ngMock : Factory\n```bash\ndescribe('Testing for new filter', function() { \n    var fromNow;\n    beforeEach(module('movieApp'));\n\n    beforeEach(inject(function (_$filter_) {\n        fromNow = _$filter_('fromNow');\n    }));\n\n    it('should return throw error for undefined', function() {\n        expect(fromNow).toThrow('date value cannot be undefined');\n    });\n});\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkssharma%2Fangular-hacks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkssharma%2Fangular-hacks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkssharma%2Fangular-hacks/lists"}