I am attempting to define a variable conn in my controller.js.
With the code at the bottom, I get lots of horrible UI glitches, so I'm presuming the code below is wrong. If I try:
var conn;
conn.name = 'Fred';
I get what looks like a NullPointer Error "Cannot set property 'name' of undefined" when I attempt to set conn.name.
How do I define my variable?
var addDBConnControllerBase = app.controller('addDBConnControllerBase',
function($scope,$http,serviceFactory,$modal,$location,$log)
{
$scope.saveDBConn = function()
{
var conn = {
name,
driverType,
connectionString,
userID,
password
};
conn.name = $scope.addDBConnController.displayName;
conn.driverType = $scope.addDBConnController.driverType;
conn.connectionString = $scope.addDBConnController.connectionString;
conn.userID = $scope.addDBConnController.userID;
conn.password = $scope.addDBConnController.password;
$log.debug('Saving db conn');
$log.debug(JSON.stringify(conn));
}
});