Skip to content

Commit

Permalink
Using AngularJS helper functions angular.isFunction angular.isString
Browse files Browse the repository at this point in the history
  • Loading branch information
nickholub committed Aug 6, 2014
1 parent 5c541a6 commit 74e2f1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions dist/angular-ui-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,15 +458,15 @@ angular.module('ui.dashboard')
link: function (scope) {

var widget = scope.widget;
var dataModelType = widget.dataModelType;
// set up data source
if (widget.dataModelType) {
if (dataModelType) {
var DataModelConstructor; // data model constructor function

var type = typeof widget.dataModelType;
if (type === 'function') {
DataModelConstructor = widget.dataModelType;
} else if (type === 'string') {
$injector.invoke([widget.dataModelType, function (DataModelType) {
if (angular.isFunction(dataModelType)) {
DataModelConstructor = dataModelType;
} else if (angular.isString(dataModelType)) {
$injector.invoke([dataModelType, function (DataModelType) {
DataModelConstructor = DataModelType;
}]);
} else {
Expand Down
13 changes: 7 additions & 6 deletions src/directives/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ angular.module('ui.dashboard')
link: function (scope) {

var widget = scope.widget;
var dataModelType = widget.dataModelType;

// set up data source
if (widget.dataModelType) {
if (dataModelType) {
var DataModelConstructor; // data model constructor function

var type = typeof widget.dataModelType;
if (type === 'function') {
DataModelConstructor = widget.dataModelType;
} else if (type === 'string') {
$injector.invoke([widget.dataModelType, function (DataModelType) {
if (angular.isFunction(dataModelType)) {
DataModelConstructor = dataModelType;
} else if (angular.isString(dataModelType)) {
$injector.invoke([dataModelType, function (DataModelType) {
DataModelConstructor = DataModelType;
}]);
} else {
Expand Down

0 comments on commit 74e2f1a

Please sign in to comment.