{"id":13316392,"url":"https://github.com/scalajs-io/angularjs","last_synced_at":"2026-04-28T05:32:59.712Z","repository":{"id":77422474,"uuid":"80953703","full_name":"scalajs-io/angularjs","owner":"scalajs-io","description":"AngularJS 1.5.x binding for Scala.js","archived":false,"fork":false,"pushed_at":"2017-03-01T09:16:02.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T22:42:43.122Z","etag":null,"topics":["angular","angularjs","mean-stack","scala","scalajs"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scalajs-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-04T22:46:28.000Z","updated_at":"2017-02-17T03:54:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd766f4e-88a1-4251-8fb5-5fee51517b07","html_url":"https://github.com/scalajs-io/angularjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fangularjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fangularjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fangularjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalajs-io%2Fangularjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalajs-io","download_url":"https://codeload.github.com/scalajs-io/angularjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242995884,"owners_count":20218815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","angularjs","mean-stack","scala","scalajs"],"created_at":"2024-07-29T18:21:38.143Z","updated_at":"2025-12-24T05:33:55.879Z","avatar_url":"https://github.com/scalajs-io.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"AngularJS API for Scala.js\n================================\nType-safe bindings for [AngularJS 1.5.x](https://docs.angularjs.org/api)\n\nAngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template \nlanguage and lets you extend HTML's syntax to express your application's components clearly and \nsuccinctly. AngularJS's data binding and dependency injection eliminate much of the code you \nwould otherwise have to write.\n\nThe following AngularJS services have been implemented thus far:\n\n| Service           | Artifact ID                    | Description                      |\n|-------------------|--------------------------------|----------------------------------|\n| $anchorScroll     | angularjs-anchor-scroll        | Anchor Scroll Service. |\n| $animate          | angularjs-animate              | The $animate service exposes a series of DOM utility methods that provide support for animation hooks. |\n| $cacheFactory     | angularjs-core                 | Factory that constructs cache objects and gives access to them. |\n| $compile          | angularjs-core                 | Compiles an HTML string or DOM into a template and produces a template function, which can then be used to link scope and the template together. |\n| $cookies          | angularjs-cookies              | Provides read/write access to browser's cookies. |\n| $cookieStore      | angularjs-cookies              | Provides a key-value (string-object) storage, that is backed by session cookies. |\n| $exceptionHandler | angularjs-core                 | Any uncaught exception in angular expressions is delegated to this service. |\n| $filter           | angularjs-core                 | Selects a subset of items from array and returns it as a new array. |\n| $http             | angularjs-core                 | The $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser's XMLHttpRequest object or via JSONP. |\n| $injector         | angularjs-core                 | $injector is used to retrieve object instances as defined by provider, instantiate types, invoke methods, and load modules. |\n| $interval         | angularjs-core                 | Angular's wrapper for window.setInterval. The fn function is executed every delay milliseconds. |\n| $location         | angularjs-core                 | The $location service parses the URL in the browser address bar (based on the window.location) and makes the URL available to your application. |\n| $log              | angularjs-core                 | Simple service for logging. Default implementation safely writes the message into the browser's console (if present). |\n| $modal            | angularjs-ui-bootstrap         | Modal Dialogs - Angular UI Bootstrap |\n| $nvd3             | angularjs-nvd3                 | An AngularJS directive for NVD3 re-usable charting library (based on D3).|\n| $parse            | angularjs-core                 | Converts Angular expression into a function. |\n| $q                | angularjs-core                 | A service that helps you run functions asynchronously, and use their return values (or exceptions) when they are done processing. |\n| $resource         | angularjs-core                 | A factory which creates a resource object that lets you interact with RESTful server-side data sources. |\n| $route            | angularjs-ui-router            | $route is used for deep-linking URLs to controllers and views (HTML partials). It watches $location.url() and tries to map the path to an existing route definition. |\n| $sce              | angularjs-sanitize             | $sce is a service that provides Strict Contextual Escaping services to AngularJS. |\n| $timeout          | angularjs-core                 | Angular's wrapper for window.setTimeout. The fn function is wrapped into a try/catch block and delegates any exceptions to $exceptionHandler service. |\n| FacebookService   | angularjs-facebook             | AngularJS - Facebook service |\n| FileUploader      | angularjs-nergvh-fileupload    | AngularJS File Uploader |\n| md5               | angularjs-md5                  | A md5 crypto component for Angular.js. |\n| toaster           | angularjs-toaster              | AngularJS Toaster is a customized version of \"toastr\" non-blocking notification javascript library. |\n\n\n### Build Requirements\n\n* [SBT v0.13.13](http://www.scala-sbt.org/download.html)\n\n\n### Build/publish the SDK locally\n\n```bash\n $ sbt clean publish-local\n```\n\n### Examples\n\n##### Service Example\n\n```scala\nimport io.scalajs.npm.angularjs._\nimport io.scalajs.npm.angularjs.http._\n\nmodule.serviceOf[MarketStatusService](\"MarketStatusSvc\")\n\n\nclass MarketStatusService($http: Http) extends Service {\n\n  def getMarketStatus(implicit ec: ExecutionContext): Future[MarketStatus] = {\n    $http.get[MarketStatus](\"/api/tradingClock/status\")\n  }\n  \n}\n\n@ScalaJSDefined\nclass MarketStatus(var stateChanged: Boolean,\n                   var active: Boolean,\n                   var sysTime: Double,\n                   var delay: Double,\n                   var start: Double,\n                   var end: Double) extends js.Object \n```\n\n##### Directive Example\n\n```scala\nmodule.directiveOf[ChangeArrowDirective](\"changearrow\")\n\nclass ChangeArrowDirective extends Directive[ChangeArrowDirectiveScope] {\n  override val restrict = \"E\"\n  override val scope = JS(value = \"@value\")\n  override val transclude = true\n  override val replace = false\n  override val template = \"\"\"\u003ci ng-class=\"icon\"\u003e\u003c/i\u003e\"\"\"\n\n  override def link(scope: ChangeArrowDirectiveScope, element: JQLite, attrs: Attributes) = {\n    scope.$watch(\"value\", { (newValue: js.UndefOr[Any], oldValue: js.UndefOr[Any]) =\u003e\n      scope.icon = newValue.toOption flatMap getNumericValue map {\n        case v if v \u003e 0 =\u003e \"fa fa-arrow-up positive\"\n        case v if v \u003c 0 =\u003e \"fa fa-arrow-down negative\"\n        case _ =\u003e \"fa fa-minus null\"\n      } orNull\n    })\n  }\n\n  private def getNumericValue(newValue: Any): Option[Double] = newValue match {\n    case n: Number =\u003e Some(n.doubleValue)\n    case s: String if s.nonEmpty =\u003e Try(s.toDouble).toOption\n    case _ =\u003e None\n  }\n}\n\n@js.native\ntrait ChangeArrowDirectiveScope extends Scope {\n  var value: js.UndefOr[Any] = js.native\n  var icon: String = js.native\n}\n\nobject ChangeArrowDirectiveScope {\n  def apply(): ChangeArrowDirectiveScope = {\n    val scope = new js.Object().asInstanceOf[ChangeArrowDirectiveScope]\n    scope.icon = null\n    scope\n  }\n}\n```\n\n##### Durations\n\nScalaJs.io provides implicit conversions so that you may use `scala.concurrent.duration.FiniteDuration`s with `$timeout`,\n`$interval`, and any other services that use time in milliseconds.\n\n```scala\n$timeout(() =\u003e doSomething(), 5.minutes)\n```\n\n##### JSON data as Scala objects\n\nScalaJs.io allows you to utilize dynamic JavaScript objects or type-safe Scala objects using traits. \nConsider the following example:\n\n```scala\n$http.get[js.Dynamic](\"/api/tradingClock/status\") onComplete {\n    case Success(status) =\u003e console.log(angular.toJson(status))\n    case Failure(e) =\u003e console.error(e.getMessage)\n}\n```\n\nAbove we retrieve a JSON object (see below) in much the same fashion as you would using native JavaScript. Sometimes\none may want to retrieve the data as a `js.Dynamic` because of the flexibility it offers.\n\n```json\n{\"stateChanged\":false,\"active\":false,\"sysTime\":1392092448795,\"delay\":-49848795,\"start\":1392042600000,\"end\":1392066000000}\n```\n\nHowever, sometimes we instead want to retrieve the data as a type-safe Scala object. ScalaJs.io makes this as simple as:\n\n```scala\n$http.get[MarketStatus](\"/api/tradingClock/status\") onComplete {\n    case Success(status) =\u003e console.log(angular.toJson(status))\n    case Failure(e) =\u003e console.error(e.getMessage)\n}\n\n@js.native\ntrait MarketStatus extends js.Object {\n    var stateChanged: Boolean = js.native\n    var active: Boolean = js.native\n    var sysTime: Double = js.native\n    var delay: Double = js.native\n    var start: Double = js.native\n    var end: Double = js.native\n}\n```\n\nAbove, we retrieve a JSON object via the given API and return a Market Status object.\n\n##### For Comprehensions\n\nScalaJs.io provides implicit conversions that convert a `HttpResponse[T]` into a `Future[T]`, we can also use `for`\ncomprehensions when we need to combine data from multiple API calls.\n\n```scala\nval outcome = for {\n   symbols \u003c- contestService.getHeldSecurities(playerId)\n   quotes \u003c- quoteService.getStockQuoteList(symbols)\n } yield quotes\n```\n\nThe above code uses Scala's for comprehension to first retrieve a collection of symbols (via REST) and then use the \nsymbols to then retrieve a collection of quotes (also via REST). \n\nTo do the same in JavaScript would've required creating \nmultiple promises (via $q) or ugly callbacks, and then there's the results gathering/error handling... which would also \nbe more painful in JavaScript. \n\nHere's how it's handled via Scala.js:\n\n```scala\noutcome onComplete {\n    case Success(updatedQuotes) =\u003e obj.quotes = updatedQuotes\n    case Failure(e) =\u003e\n        toaster.error(\"Failed to load Held Securities\")\n        console.error(s\"Failed to load Held Securities: ${e.getMessage}\")\n}\n```\n\n\n### Artifacts and Resolvers\n\nTo add the Moment binding to your project, add the following to your build.sbt:  \n\n```sbt\nlibraryDependencies += \"io.scalajs.npm\" %%% \"angularjs-bundle\" % \"0.3.0.6\"\n```\n\nOptionally, you may add the Sonatype Repository resolver:\n\n```sbt   \nresolvers += Resolver.sonatypeRepo(\"releases\") ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalajs-io%2Fangularjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalajs-io%2Fangularjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalajs-io%2Fangularjs/lists"}