Recently, I created a custom Angular directive.
<location zipcode="35423" cityname="" statecode=""></location>
Within the directive, I defined the following:
scope: {
zipcode: "@",
cityname: "@",
statecode: "@"
},
When setting up the controller for the directive, I encountered the following:
controller: function ($scope, $filter) {
$scope.zipcode = "35423" // assigned the value here
$scope.cityname = undefined // why is this undefined?
$scope.statecode= undefined // why is this undefined?
}
My goal is to have $scope.cityname = ""
It's worth mentioning that I am using an MVC application.
zipcode="@ZipCode" cityname="@City" statecode="@StateCode"
Additionally, in some cases, City
might be null.