Skip to content

Commit 99909f9

Browse files
committed
Make example work in IE by adding Object.assign
1 parent a4fc4a9 commit 99909f9

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

examples/example.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,33 @@
8787
}
8888

8989
</style>
90+
91+
<script type="text/javascript">
92+
if (typeof Object.assign != 'function') {
93+
Object.assign = function(target, varArgs) { // .length of function is 2
94+
'use strict';
95+
if (target == null) { // TypeError if undefined or null
96+
throw new TypeError('Cannot convert undefined or null to object');
97+
}
98+
99+
var to = Object(target);
100+
101+
for (var index = 1; index < arguments.length; index++) {
102+
var nextSource = arguments[index];
103+
104+
if (nextSource != null) { // Skip over if undefined or null
105+
for (var nextKey in nextSource) {
106+
// Avoid bugs when hasOwnProperty is shadowed
107+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
108+
to[nextKey] = nextSource[nextKey];
109+
}
110+
}
111+
}
112+
}
113+
return to;
114+
};
115+
}
116+
</script>
90117
</head>
91118
<body ng-app="test" ng-controller="TestCtrl" ng-cloak>
92119
<nav class="navbar navbar-default">
@@ -339,7 +366,7 @@ <h3>Schema</h3>
339366
};
340367

341368
$scope.pretty = function(){
342-
return typeof $scope.modelData === 'string' ? $scope.modelData : JSON.stringify($scope.modelData, undefined, 2);
369+
return typeof $scope.modelData === 'string' ? $scope.modelData : angular.toJson($scope.modelData);
343370
};
344371

345372
$scope.log = function(msg){

0 commit comments

Comments
 (0)