npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-container

v0.1.4

Published

[![NPM version](https://img.shields.io/npm/v/angular-container.svg)](https://www.npmjs.org/package/angular-container) ![](https://img.shields.io/npm/dm/angular-container.svg) ![](https://img.shields.io/github/last-commit/opteo/angular-container.svg) # Ang

Downloads

2

Readme

NPM version

Angular Container

Here at Opteo, we recently undertook the process of updating our large, Angular.js-based, front-end application (composed of many controllers, services and directives) to Vue. Migrating our entire application was expected to take several weeks (which later became months), so we built the angular-container Vue component as a simple way to use our existing Angular pages within our new Vue-based app.

Features

  • Use existing Angular based controllers/services/directives within .vue components
  • Allows for an easier migration process to Vue when working with a large existing Angular codebase
  • Can be lazily loaded for only pages which require Angular

Notes:

By default, non curly braces are used for rendering angular-container $scope variables, and instead square brackets are used (this can be overwritten). The default is due to Vue using curly braces for data binding, which causes mounting issues and conflicts.

Installation

An installation of Angular.js is required for this component to work correctly. Install via yarn or npm:

yarn add angular angular-container

Example

<template>
  <AngularContainer ref="ng" name="user" ctrl="userCtrl">
    <div ng-for="item in items">
      <span ng-click="addItem()">[[ item ]]</span>
      
      <!-- Existing custom Angular directives can be used -->
      <blue>This users the "blue" directive</blue>
      
      <!-- Vue variables can be used within the Angular instance -->
      <span>{{ hello }}</span>
    </div>
  </AngularContainer>
</template>
<script>
import AngularContainer from "angular-container"

export default {
  name: "User",
  data() {
    return {
      hello: "world",
    }
  },
  mounted() {
    const angularContainer = this.$refs.ng
    angularContainer.init() // Instantiate the Angular.js instance after Vue has mounted
    const angularInstance = angularContainer.getInstance()
    
    /* Use controllers, services and directives that you need */
    angularInstance.service("userService", ["$injector", ($injector)  => {
      return {
        getSomeData() {
          return fetch("https://example.com/api/")
        }
      }
    }])
    
    // Controller    
    angularInstance.controller("userCtrl", ["$scope", "userService", ($scope, userService) => {
      $scope.items = [1, 2, 3, 4, 5]
      $scope.addItem = () => $scope.items.push(Math.random())
      const data = await userService.getSomeData()
    }])
    
    // Directive
    angularInstance.directive("blue", () => {
      return {
        restrict: "E",
        transclude: true,
        template: `<span style="color:blue;" ng-transclude></span>`
      }
    })
  },
  components: {
    AngularContainer,
  }
}
</script>