Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
angularjs-oasis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miracle Agomishor Modey
angularjs-oasis
Commits
182d982c
Commit
182d982c
authored
6 years ago
by
Miracle Agomishor Modey
Browse files
Options
Downloads
Patches
Plain Diff
Add new file
parent
af92556d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assignment 2/index.html
+111
-0
111 additions, 0 deletions
Assignment 2/index.html
with
111 additions
and
0 deletions
Assignment 2/index.html
0 → 100644
+
111
−
0
View file @
182d982c
<!DOCTYPE html>
<html>
<head>
<title>
How to convert number to words in Angularjs?
</title>
<script
src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js"
></script>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"
></script>
</head>
<body
ng-app=
"MyApp"
>
<div
ng-controller=
"myFormController"
>
<form
name=
"myForm"
>
Nominal Share Capital :
<input
type=
"text"
ng-pattern=
"/^[0-9]*$/"
ng-minlength=
4
ng-model=
"nominalshare"
name=
"nominalshare"
>
<span
style=
"color:red"
ng-show=
"myForm.nominalshare.$error.pattern"
>
Only Numbers are allowed
</span>
<span
style=
"color:red"
ng-show=
"myForm.nominalshare.$error.minlength"
>
Value is too short
</span>
<br>
Nominal Share in Words :
<input
ng-value=
"nominalshare | words"
ng-disabled=
"!nominalshare"
>
<br>
Nominal Share Price :
<input
type=
"text"
ng-pattern=
"/^[0-9]*$/"
ng-disabled=
"!nominalshare"
ng-model=
"price"
name=
"price"
>
<span
style=
"color:red"
ng-show=
"myForm.price.$error.pattern"
>
Only Numbers are allowed
</span>
<br>
Division :
<input
name=
"division"
ng-pattern=
"/^[0-9]*$/"
ng-disabled=
"!price"
ng-value=
"(nominalshare)/(price)"
>
<span
style=
"color:red"
ng-show=
"myForm.division.$error.pattern"
>
Please type a divisible number in Nominal Share Price
</span>
<br>
<input
type=
"submit"
ng-model=
"submit"
ng-value=
"Submit"
ng-disabled=
"!nominalshare"
>
<br>
</form>
</div>
<script
type=
"text/javascript"
>
var
MyApp
=
angular
.
module
(
'
MyApp
'
,[]);
MyApp
.
controller
(
'
myFormController
'
,[
'
$scope
'
,
function
(
$scope
){
$scope
.
nominalshare
=
''
;
$scope
.
division
=
''
;
}]);
MyApp
.
filter
(
'
words
'
,
function
()
{
function
isInteger
(
query
)
{
return
query
%
1
===
0
;
}
return
function
(
value
)
{
if
(
value
&&
isInteger
(
value
))
return
covertWords
(
value
);
return
value
;
};
});
var
myappthos
=
[
''
,
'
thousand
'
,
'
million
'
,
'
billion
'
,
'
trillion
'
];
var
myappdang
=
[
'
zero
'
,
'
one
'
,
'
two
'
,
'
three
'
,
'
four
'
,
'
five
'
,
'
six
'
,
'
seven
'
,
'
eight
'
,
'
nine
'
];
var
myapptenth
=
[
'
ten
'
,
'
eleven
'
,
'
twelve
'
,
'
thirteen
'
,
'
fourteen
'
,
'
fifteen
'
,
'
sixteen
'
,
'
seventeen
'
,
'
eighteen
'
,
'
nineteen
'
];
var
myapptvew
=
[
'
twenty
'
,
'
thirty
'
,
'
forty
'
,
'
fifty
'
,
'
sixty
'
,
'
seventy
'
,
'
eighty
'
,
'
ninety
'
];
function
covertWords
(
s
)
{
s
=
s
.
toString
();
s
=
s
.
replace
(
/
[\,
]
/g
,
''
);
// if (parseFloat(s) === NaN) return 'not a number';
var
query
=
s
.
indexOf
(
'
.
'
);
// if (parseInt(query) === NaN) return 'not a number';
if
(
query
==
-
1
)
query
=
s
.
length
;
//if (query
<
4
)
return
'
too small
'
;
var
n
=
s
.
split
(
''
);
var
str
=
''
;
var
mjk
=
0
;
for
(
var
ld
=
0
;
ld
<
query
;
ld
++
)
{
if
((
query
-
ld
)
%
3
==
2
)
{
if
(
n
[
ld
]
==
'
1
'
)
{
str
+=
myapptenth
[
Number
(
n
[
ld
+
1
])]
+
'
'
;
ld
++
;
mjk
=
1
;
}
else
if
(
n
[
ld
]
!=
0
)
{
str
+=
myapptvew
[
n
[
ld
]
-
2
]
+
'
'
;
mjk
=
1
;
}
}
else
if
(
n
[
ld
]
!=
0
)
{
str
+=
myappdang
[
n
[
ld
]]
+
'
'
;
if
((
query
-
ld
)
%
3
==
0
)
str
+=
'
hundred
'
;
mjk
=
1
;
}
if
((
query
-
ld
)
%
3
==
1
)
{
if
(
mjk
)
str
+=
myappthos
[(
query
-
ld
-
1
)
/
3
]
+
'
'
;
mjk
=
0
;
}
}
if
(
query
!=
s
.
length
)
{
var
dv
=
s
.
length
;
str
+=
'
point
'
;
for
(
var
ld
=
query
+
1
;
ld
<
dv
;
ld
++
)
str
+=
myappdang
[
n
[
ld
]]
+
'
'
;
}
return
str
.
replace
(
/
\s
+/g
,
'
'
);
}
window
.
covertWords
=
covertWords
;
</script>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment