bindings/angular1/services/onsen.js
function(name, object) {
          var names = name.split(/\./);

          function set(container, names, object) {
            var name;
            for (var i = 0; i < names.length - 1; i++) {
              name = names[i];
              if (container[name] === undefined || container[name] === null) {
                container[name] = {};
              }
              container = container[name];
            }

            container[names[names.length - 1]] = object;

            if (container[names[names.length - 1]] !== object) {
              throw new Error('Cannot set var="' + object._attrs.var + '" because it will overwrite a read-only variable.');
            }
          }

          if (ons.componentBase) {
            set(ons.componentBase, names, object);
          }

          var getScope = function(el) {
            return angular.element(el).data('_scope');
          };

          var element = object._element[0];

          // Current element might not have data('_scope')
          if (element.hasAttribute('ons-scope')) {
            set(getScope(element) || object._scope, names, object);
            element = null;
            return;
          }

          // Ancestors
          while (element.parentElement) {
            element = element.parentElement;
            if (element.hasAttribute('ons-scope')) {
              set(getScope(element), names, object);
              element = null;
              return;
            }
          }

          element = null;

          // If no ons-scope element was found, attach to $rootScope.
          set($rootScope, names, object);
        }
function(name, object) {
          var names = name.split(/\./);

          function set(container, names, object) {
            var name;
            for (var i = 0; i < names.length - 1; i++) {
              name = names[i];
              if (container[name] === undefined || container[name] === null) {
                container[name] = {};
              }
              container = container[name];
            }

            container[names[names.length - 1]] = object;

            if (container[names[names.length - 1]] !== object) {
              throw new Error('Cannot set var="' + object._attrs.var + '" because it will overwrite a read-only variable.');
            }
          }

          if (ons.componentBase) {
            set(ons.componentBase, names, object);
          }

          var getScope = function(el) {
            return angular.element(el).data('_scope');
          };

          var element = object._element[0];

          // Current element might not have data('_scope')
          if (element.hasAttribute('ons-scope')) {
            set(getScope(element) || object._scope, names, object);
            element = null;
            return;
          }

          // Ancestors
          while (element.parentElement) {
            element = element.parentElement;
            if (element.hasAttribute('ons-scope')) {
              set(getScope(element), names, object);
              element = null;
              return;
            }
          }

          element = null;

          // If no ons-scope element was found, attach to $rootScope.
          set($rootScope, names, object);
        }
function ( name , object ) { var names = name . split ( / \. / ) ; function set ( container , names , object ) { var name ; for ( var i = 0 ; i < names . length - 1 ; i ++ ) { name = names [ i ] ; if ( container [ name ] === undefined || container [ name ] === null ) { container [ name ] = { } ; } container = container [ name ] ; } container [ names [ names . length - 1 ] ] = object ; if ( container [ names [ names . length - 1 ] ] !== object ) { throw new Error ( 'Cannot set var="' + object . _attrs . var + '" because it will overwrite a read-only variable.' ) ; } } if ( ons . componentBase ) { set ( ons . componentBase , names , object ) ; } var getScope = function ( el ) { return angular . element ( el ) . data ( '_scope' ) ; } ; var element = object . _element [ 0 ] ; // Current element might not have data('_scope') if ( element . hasAttribute ( 'ons-scope' ) ) { set ( getScope ( element ) || object . _scope , names , object ) ; element = null ; return ; } // Ancestors while ( element . parentElement ) { element = element . parentElement ; if ( element . hasAttribute ( 'ons-scope' ) ) { set ( getScope ( element ) , names , object ) ; element = null ; return ; } } element = null ; // If no ons-scope element was found, attach to $rootScope. set ( $rootScope , names , object ) ; }
Define a variable to JavaScript global scope and AngularJS scope.

Util.defineVar('foo', 'foo-value');
// => window.foo and $scope.foo is now 'foo-value'

Util.defineVar('foo.bar', 'foo-bar-value');
// => window.foo.bar and $scope.foo.bar is now 'foo-bar-value'

@param {String} name
@param object
Define a variable to JavaScript global scope and AngularJS scope .