uncaught typeError:无法设置属性' src' of null:file:///android_asset/www/cordova.js; 312

时间:2015-10-01 13:25:36

标签: javascript html angularjs cordova ionic-framework

我是离子新手并试图将Google-Plus集成到我的应用程序中。 每件事情都很好但是在这个过程的最后一步我得到了上面提到的错误。我不知道解决这个错误我用谷歌搜索但无法解决它,所以最后我来这里寻求你的帮助

这是我的app.js文件: -



var app = angular.module('ionicApp', [ 'ionic' ])

app.config(function($stateProvider, $urlRouterProvider) {

	$stateProvider.state('app', {
		url : '/app',
		abstract : true,
		templateUrl : 'templates/menu.html',
	})

	.state('login', {
		url : "/login",
		templateUrl : "templates/login.html",
		controller : "LoginCtrl"
	})

	.state('app.home', {
		url : '/home',
		views : {
			'menuContent' : {
				templateUrl : 'templates/home.html'
			}
		}
	})

	.state('app.products', {
		url : '/products',
		views : {
			'menuContent' : {
				templateUrl : 'templates/products.html'
			}
		}
	})

	.state('app.products-details', {
		url : '/products-details',
		views : {
			'menuContent' : {
				templateUrl : 'templates/products-details.html'
			}
		}
	})

	.state('app.cart', {
		url : '/cart',
		views : {
			'menuContent' : {
				templateUrl : 'templates/cart.html'
			}
		}
	})

	.state('app.checkout', {
		url : '/checkout',
		views : {
			'menuContent' : {
				templateUrl : 'templates/checkout.html'
			}
		}
	})

	.state('app.register', {
		url : '/register',
		views : {
			'menuContent' : {
				templateUrl : 'templates/register.html'
			}
		}
	})

	.state('app.categories', {
		url : '/categories',
		views : {
			'menuContent' : {
				templateUrl : 'templates/categories.html'
			}
		}
	})

	.state('app.search', {
		url : '/search',
		views : {
			'menuContent' : {
				templateUrl : 'templates/search.html'
			}
		}
	})

	.state('app.profile', {
		url : '/profile',
		views : {
			'menuContent' : {
				templateUrl : 'templates/profile.html'
			}
		}
	})

	.state('app.change-pass', {
		url : '/change-pass',
		views : {
			'menuContent' : {
				templateUrl : 'templates/change-pass.html'
			}
		}
	})

	.state('app.profile-page', {
		url : '/profile-page',
		views : {
			'menuContent' : {
				templateUrl : 'templates/profile-page.html'
			}
		}
	})

	.state('app.myorders', {
		url : '/myorders',
		views : {
			'menuContent' : {
				templateUrl : 'templates/myorders.html'
			}
		}
	})

	.state('app.delivery', {
		url : '/delivery',
		views : {
			'menuContent' : {
				templateUrl : 'templates/delivery.html'
			}
		}
	})

	.state('app.placeorder', {
		url : '/placeorder',
		views : {
			'menuContent' : {
				templateUrl : 'templates/placeorder.html'

			}
		}
	})

	.state('app.splash', {
		url : '/splash',
		views : {
			'menuContent' : {
				templateUrl : 'templates/splash.html'
			}
		}
	})

	.state('app.paymethod', {
		url : '/paymethod',
		views : {
			'menuContent' : {
				templateUrl : 'templates/paymethod.html'
			}
		}
	})

	$urlRouterProvider.otherwise("/login");
});

app.controller('MainCtrl', function($scope, $state, $ionicSideMenuDelegate) {

	$scope.create = function() {
		$state.go('app.category');
	};
	$scope.close = function() {
		$state.go('app.products');
	};

	// categories accordian
	$scope.groups = [];
	for ( var i = 0; i < 10; i++) {
		$scope.groups[i] = {
			name : i,
			items : []
		};
		for ( var j = 0; j < 3; j++) {
			$scope.groups[i].items.push(i + '-' + j);
		}
	}

	/*
	 * if given group is the selected group, deselect it else, select the given
	 * group
	 */
	$scope.toggleGroup = function(group) {
		if ($scope.isGroupShown(group)) {
			$scope.shownGroup = null;
		} else {
			$scope.shownGroup = group;
		}
	};
	$scope.isGroupShown = function(group) {
		return $scope.shownGroup === group;
	};

});
&#13;
&#13;
&#13;

这是我的controllers.js文件: -

&#13;
&#13;
app
		.controller(
				'LoginCtrl',
				function($scope, $stateParams) {
					$scope.login = function() {
						window.plugins.googleplus
								.login(
										{},
										function(obj) {
											document.querySelector("#image").src = obj.imageUrl;
											document.querySelector("#image").style.visibility = 'visible';
											document.querySelector("#feedback").innerHTML = "Hi, "
													+ obj.displayName
													+ ", "
													+ obj.email;
										},
										function(msg) {
											document.querySelector("#feedback").innerHTML = "error: "
													+ msg;
										});
					}
					window.onerror = function(what, line, file) {
						alert(what + '; ' + line + '; ' + file);
					};
					function handleOpenURL(url) {
						document.querySelector("#feedback").innerHTML = "App was opened by URL: "
								+ url;
					}
				});
&#13;
&#13;
&#13;

这是我的config.xml

&#13;
&#13;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget xmlns:cdv="http://cordova.apache.org/ns/1.0"
    xmlns:gap="http://phonegap.com/ns/1.0"
    id="com.ionicframework.ecommerce785960"
    version="0.0.1"
    xmlns="http://www.w3.org/ns/widgets" >

    <name>
e-commerce
    </name>

    <description>
        An Ionic Framework and Cordova project.
    </description>

    <author
        email="hi@ionicframework"
        href="http://ionicframework.com/" >
      Ionic Framework Team
    </author>

    <content src="index.html" />

    <access origin="*" />

    <preference
        name="webviewbounce"
        value="false" />

    <preference
        name="UIWebViewBounce"
        value="false" />

    <preference
        name="DisallowOverscroll"
        value="true" />

    <preference
        name="android-minSdkVersion"
        value="16" />

    <preference
        name="BackupWebStorage"
        value="none" />

    <preference
        name="SplashScreen"
        value="screen" />

    <preference
        name="SplashScreenDelay"
        value="3000" />

    <feature name="StatusBar" >

        <param
            name="ios-package"
            onload="true"
            value="CDVStatusBar" />
    </feature>

    <platform name="android" >

        <icon
            density="ldpi"
            src="resources/android/icon/drawable-ldpi-icon.png" />

        <icon
            density="mdpi"
            src="resources/android/icon/drawable-mdpi-icon.png" />

        <icon
            density="hdpi"
            src="resources/android/icon/drawable-hdpi-icon.png" />

        <icon
            density="xhdpi"
            src="resources/android/icon/drawable-xhdpi-icon.png" />

        <icon
            density="xxhdpi"
            src="resources/android/icon/drawable-xxhdpi-icon.png" />

        <icon
            density="xxxhdpi"
            src="resources/android/icon/drawable-xxxhdpi-icon.png" />

        <splash
            density="land-ldpi"
            src="resources/android/splash/drawable-land-ldpi-screen.png" />

        <splash
            density="land-mdpi"
            src="resources/android/splash/drawable-land-mdpi-screen.png" />

        <splash
            density="land-hdpi"
            src="resources/android/splash/drawable-land-hdpi-screen.png" />

        <splash
            density="land-xhdpi"
            src="resources/android/splash/drawable-land-xhdpi-screen.png" />

        <splash
            density="land-xxhdpi"
            src="resources/android/splash/drawable-land-xxhdpi-screen.png" />

        <splash
            density="land-xxxhdpi"
            src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />

        <splash
            density="port-ldpi"
            src="resources/android/splash/drawable-port-ldpi-screen.png" />

        <splash
            density="port-mdpi"
            src="resources/android/splash/drawable-port-mdpi-screen.png" />

        <splash
            density="port-hdpi"
            src="resources/android/splash/drawable-port-hdpi-screen.png" />

        <splash
            density="port-xhdpi"
            src="resources/android/splash/drawable-port-xhdpi-screen.png" />

        <splash
            density="port-xxhdpi"
            src="resources/android/splash/drawable-port-xxhdpi-screen.png" />

        <splash
            density="port-xxxhdpi"
            src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>

    <gap:plugin
        name="cordova-plugin-googleplus"
        source="npm" >

        <param
            name="REVERSED_CLIENT_ID"
            value="974087359524-ta7cv0tivlt16iladpoeud75f2g5so9i.apps.googleusercontent.com" />
    </gap:plugin>

</widget>
&#13;
&#13;
&#13;

这是我的index.html: -

&#13;
&#13;
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>

</head>
<body ng-controller="MainCtrl">

	<ion-nav-view></ion-nav-view>

</body>
&#13;
&#13;
&#13;

我在我的应用程序中集成google plus的步骤: -

https://github.com/EddyVerbruggen/cordova-plugin-googleplus/blob/master/demo/index.html

任何帮助将不胜感激。 感谢。

0 个答案:

没有答案