src/services/view-manager.js
function(id, view) {
    // No id
    if(!id) {
      throw new Error('View requires an id.');

    // Require unique id
    } else if(_viewHash[id]) {
      throw new Error('View requires a unique id');

    // Add
    } else {
      _viewHash[id] = view;
    }

    // Check if view is currently active
    var current = $state.current() || {};
    var templates = current.templates || {};
    var controllers = current.controllers || {};
    if(!!templates[id]) {
      _renderView(id, view, templates[id], controllers[id]);
    }

    // Implement destroy method
    view.destroy = function() {
      _unregister(id);
    };

    return view;
  }
function(id, view) {
    // No id
    if(!id) {
      throw new Error('View requires an id.');

    // Require unique id
    } else if(_viewHash[id]) {
      throw new Error('View requires a unique id');

    // Add
    } else {
      _viewHash[id] = view;
    }

    // Check if view is currently active
    var current = $state.current() || {};
    var templates = current.templates || {};
    var controllers = current.controllers || {};
    if(!!templates[id]) {
      _renderView(id, view, templates[id], controllers[id]);
    }

    // Implement destroy method
    view.destroy = function() {
      _unregister(id);
    };

    return view;
  }
function ( id , view ) { // No id if ( ! id ) { throw new Error ( 'View requires an id.' ) ; // Require unique id } else if ( _viewHash [ id ] ) { throw new Error ( 'View requires a unique id' ) ; // Add } else { _viewHash [ id ] = view ; } // Check if view is currently active var current = $state . current ( ) || { } ; var templates = current . templates || { } ; var controllers = current . controllers || { } ; if ( ! ! templates [ id ] ) { _renderView ( id , view , templates [ id ] , controllers [ id ] ) ; } // Implement destroy method view . destroy = function ( ) { _unregister ( id ) ; } ; return view ; }
Register a view, also implements destroy method on view to unregister from manager

@param  {String}       id   Unique identifier for view
@param  {View}         view A view instance
@return {$viewManager}      Itself, chainable
Register a view also implements destroy method on view to unregister from manager